RustTip

OnElevatorButtonPress

OxideCarbonElevator

Called when elevator button press occurs.

object OnElevatorButtonPress(ElevatorLift elevatorLift, BasePlayer player, int local0, bool local1)
Works — the game method in this build is the one the hook was written for.

Parameters

elevatorLift
ElevatorLift
player
BasePlayer
local0
int
local1
bool

Return value

objectReturn non-null to cancel the game action.

Example

object — you can affect the game: return a value to change or cancel the action.

private object OnElevatorButtonPress(ElevatorLift elevatorLift, BasePlayer player, int local0, bool local1)
{
    Puts("OnElevatorButtonPress");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return false; // non-null cancels the game action
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
void ElevatorLift.Server_RaiseLowerFloor(BaseEntity.RPCMessage)

Passes: ElevatorLift elevatorLift, BasePlayer player, int local0, bool local1

WorksReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (this, a0.player, l0, l1)Assembly-CSharp.dll

Where it is called (this branch's game code)

[RPC_Server]
[RPC_Server.IsVisible(3f)]
public void Server_RaiseLowerFloor(RPCMessage msg)
{
	int num = msg.read.Int32();
	bool relative = msg.read.Bool();
	if (Interface.CallHook("OnElevatorButtonPress", this, msg.player, num, relative) != null)
	{
		return;
	}
	owner.Server_RaiseLowerElevator(num, relative, out var wantsMoveUp);
	using (FlagsUpdateScope flagsUpdateScope = StartSetFlags(FlagsUpdateMode.SendNetworkUpdate))
	{
		flagsUpdateScope.Set(wantsMoveUp ? Flags.Reserved1 : Flags.Reserved2, b: true);
		flagsUpdateScope.Set(Flags.Reserved6, num == int.MinValue || num == int.MaxValue);
// …

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.