OnSiegeWeaponDoorOpen
OnSiegeWeaponDoorOpen is called when a player in a BatteringRam attempts to open a siege weapon door, before the door actually opens. Returning a non-null value cancels the open.
object OnSiegeWeaponDoorOpen(BatteringRam batteringRam, BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
batteringRam | BatteringRam | The BatteringRam siege weapon whose driver is trying to open the door. Use it to read the entity's position, owner, health or to call Kill() to destroy the ram. |
player | BasePlayer | The BasePlayer occupying the ram who triggered the open RPC. Check permissions, teams or building authorization against this player. |
Return value
Returning null lets the original OpenDoor() call run and the siege door opens. Returning any non-null object cancels the open โ the door stays shut and the ram keeps its previous state; the return value itself is not used.
How it works
The hook fires inside BatteringRam.RPC_OpenDoor, the RPC a player sends from the driver seat of a battering ram to open the attached siege door. Oxide calls it only after the player passes CanInteract and the ram reports CanOpenDoor(), so the player is seated, alive and interacting with the ram at that point. Returning a non-null value stops OpenDoor() from running; returning null lets the door open normally.
Both arguments are already validated by the game: batteringRam is the ram entity the RPC arrived on and player is rpc.player, the player who sent it. There is no separate world position argument โ use batteringRam.transform.position or player.transform.position if you need coordinates. Because the ram has a fixed owner and optional occupants, player may be the owner or a passenger who boarded the vehicle; verify who is actually allowed to operate it.
This is a primitive hook with a single injection site, so it does not fire for regular doors, code locks or other vehicles. Declaring either parameter as a more specific type has little value here because both types are already exact; the useful narrowing is behavioral, not type based.
Example plugin: Restrict siege door opening to the ram owner and teammates
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Siege Ram Door Guard", "RustPluginGenerator", "1.0.0")]
[Description("Restricts opening a BatteringRam siege door to the owner and their team.")]
public class SiegeRamDoorGuard : RustPlugin
{
private const string PermBypass = "siegeramdoorguard.bypass";
private class PluginConfig
{
[JsonProperty("Allow team members")]
public bool AllowTeamMembers { get; set; } = true;
[JsonProperty("Notify blocked players")]
public bool NotifyBlocked { get; set; } = true;
}
private PluginConfig config;
protected override void LoadDefaultConfig() => config = new PluginConfig();
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<PluginConfig>();
if (config == null) throw new Exception();
}
catch
{
PrintWarning("Configuration file is invalid, using defaults");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["Blocked"] = "Only the owner of this ram or their team can open the siege door.",
["Logged"] = "Blocked {0} ({1}) from opening a siege door at {2}."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
=> string.Format(lang.GetMessage(key, this, userId), args);
private void Init()
{
permission.RegisterPermission(PermBypass, this);
}
private object OnSiegeWeaponDoorOpen(BatteringRam batteringRam, BasePlayer player)
{
if (batteringRam == null || player == null) return null;
if (!config.AllowTeamMembers && false) return null;
if (permission.UserHasPermission(player.UserIDString, PermBypass)) return null;
ulong ownerId = batteringRam.OwnerID;
if (ownerId == 0) return null;
if (player.userID == ownerId) return null;
if (config.AllowTeamMembers && player.currentTeam != 0)
{
var team = RelationshipManager.ServerInstance.FindTeam(player.currentTeam);
if (team != null && team.members.Contains(ownerId)) return null;
}
if (config.NotifyBlocked)
{
player.ChatMessage(Msg("Blocked", player.UserIDString));
}
Vector3 pos = batteringRam.transform.position;
PrintWarning(string.Format(Msg("Logged", null, player.displayName, player.UserIDString,
$"({pos.x:F0}, {pos.y:F0}, {pos.z:F0})")));
return true;
}
}
}The plugin blocks any passenger from opening a battering ram's door unless they are the entity owner or share the owner's team. In the hook it reads OwnerID from the ram, compares it with player.userID, and uses RelationshipManager.ServerInstance.FindTeam to check the owner's team member list. Blocked attempts are cancelled by returning true, and the offending player receives a localized chat message through the language file. The config stores a toggle so admins can disable the restriction without unloading the plugin, and a siegeram.guard.bypass permission lets selected players (for example event staff) open doors regardless of ownership.
Common use cases
Team-only siege ram access
Reject opens from players who are neither the ram owner nor in the owner's team, so a stolen or borrowed ram cannot be operated by outsiders.
Event control of ram doors
During a raid event, block all door opens until a staff member with a permission triggers an in-memory flag, then let players operate the ram freely.
Logging suspicious opens
Record blocked attempts with the player's name, id and ram position for admin review after a raid.
Pitfalls
Returning false also blocks
The injection treats any non-null return as a cancel. Returning
falsestops the door from opening just like returningtrue; return null when you want to allow it.Owner is not always the driver
Any seated player can send the RPC. If you only check
batteringRam.OwnerID, a passenger on the same team passes silently, so decide explicitly whether team members should be allowed.No direct door reference
The hook does not expose the siege door itself, only the ram and player. Use
batteringRam.transform.positionfor logging or proximity checks instead of expecting a door entity.
Build a plugin with OnSiegeWeaponDoorOpen
Describe what should happen and get a compiled plugin that uses this hook.
Edit the prompt on the next screen. 2 free plugins a month, no card.
Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.
Build a plugin with OnSiegeWeaponDoorOpen
Generate