OnSiegeWeaponDoorClose
OnSiegeWeaponDoorClose is called when a player requests to close the protective door on a deployed BatteringRam, before the door actually closes.
object OnSiegeWeaponDoorClose(BatteringRam batteringRam, BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
batteringRam | BatteringRam | The BatteringRam siege weapon whose door is being closed. Use it to read position, owner, or the door state via CanCloseDoor-style checks you perform yourself. |
player | BasePlayer | The BasePlayer who sent the close-door RPC. This is the player interacting with the ram, not necessarily the owner; it can be null in edge cases, so null-check before using it. |
Return value
Returning null lets the original CloseDoor() run as normal. Returning any non-null value (for example true) suppresses the close, leaving the door open; the return type is object, so any non-null object blocks it.
How it works
This hook fires inside BatteringRam.RPC_CloseDoor, the server RPC a client sends when the player presses the close control on the ram's door. The game only reaches the hook after rpc.player.CanInteract() passes and CanCloseDoor() returns true, so by the time you run, the player is able to interact and the door is in a state that can be closed. The call sits between those checks and the actual CloseDoor() call, which makes it a veto point.
The parameters are the ram itself (batteringRam) and the requesting player (player). Both are concrete types already, so declaring BatteringRam and BasePlayer keeps Oxide dispatch matching every call; narrowing player to a subtype would skip calls where the argument is a different type.
Use it for access rules, raid-window gating, or logging who is operating a siege weapon. Returning a non-null value stops the door from closing; return null to let the game proceed. Because this fires on a client RPC, spam is possible — avoid heavy work and never print to console here.
Example plugin: Block closing the ram door during a raid protection window
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Siege Ram Door Guard", "RustPluginGenerator", "1.0.0")]
[Description("Restricts who may close the door on a deployed BatteringRam.")]
public class SiegeRamDoorGuard : RustPlugin
{
private const string PermBypass = "siegeramdoorguard.bypass";
private PluginConfig config;
public class PluginConfig
{
[JsonProperty("Enable restriction")]
public bool Enabled { get; set; } = true;
}
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>
{
["NotAllowed"] = "You are not permitted to close the door on this siege weapon."
}, 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 OnSiegeWeaponDoorClose(BatteringRam batteringRam, BasePlayer player)
{
if (batteringRam == null || player == null)
return null;
if (!config.Enabled)
return null;
if (player.IsAdmin || permission.UserHasPermission(player.UserIDString, PermBypass))
return null;
// Refuse the close request: any non-null return cancels CloseDoor().
player.ChatMessage(Msg("NotAllowed", player.UserIDString));
return true;
}
}
}The plugin keeps a config flag and a permission. In OnSiegeWeaponDoorClose it null-checks the parameters, then, when the guard flag is enabled, checks whether the requester holds the bypass permission siegeramdoorguard.bypass. Players without it are refused: the hook returns true, which is non-null and therefore prevents CloseDoor() from running, and the player gets a localized chat message. Everyone else and admins fall through with null, so the door closes normally. Messages go through the language file, and no logging happens inside the hook to keep RPC-driven calls cheap.
Common use cases
Permission-gated ram control
Only allow players with a specific permission to close the ram door, returning non-null for everyone else so the door stays open.
Owner-only operation
Compare
player.userIDagainst the ram'sOwnerIDand block non-owners from closing the door on someone else's deployed ram.Audit of siege weapon use
Record which players close ram doors into an Oxide data file, useful for tracking who is operating raid equipment.
Pitfalls
Check CanCloseDoor is already satisfied
The hook only runs after the game's own interact and door-state checks pass, so you never need to re-test whether the door can close; focus on your own access rules.
Player may be null
Null-check
playerbefore readingUserIDStringor callingChatMessage, otherwise a malformed RPC can throw inside the hook.It is a client-triggered RPC
Do not run expensive queries or PrintWarning here; the client controls how often the RPC is sent, so keep the body short.
Build a plugin with OnSiegeWeaponDoorClose
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 OnSiegeWeaponDoorClose
Generate