RustTip

OnCupboardAuthorize

OxideCarbonStructure

Called when cupboard authorize occurs.

object OnCupboardAuthorize(BuildingPrivlidge priv, BasePlayer player)
object OnCupboardAuthorize(VehiclePrivilege vehiclePrivilege, BasePlayer player)
Works — the game method in this build is the one the hook was written for.

Parameters

priv
BuildingPrivlidge
player
BasePlayer

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 OnCupboardAuthorize(BuildingPrivlidge priv, BasePlayer player)
{
    Puts("OnCupboardAuthorize");

    // 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.

Where it is called

Oxide core (Oxide.Rust)
RustCore::IOnCupboardAuthorize(ulong userID, BasePlayer player, BuildingPrivlidge privlidge)

Oxide core code — the hook is called from here

private object IOnCupboardAuthorize(ulong userID, BasePlayer player, BuildingPrivlidge privlidge)
{
    if (userID == player.userID)
    {
        if (Interface.CallHook("OnCupboardAuthorize", privlidge, player) != null)
        {
            return true;
        }
    }
    else if (Interface.CallHook("OnCupboardAssign", privlidge, userID, player) != null)
    {
        return true;
    }
// …

Injection point 1

Rust.opj (Oxide)
void ItemModDeployable.OnDeployed(BaseEntity, BasePlayer)

Passes: BuildingPrivlidge priv, BasePlayer player

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l0, a1)Assembly-CSharp.dll

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

internal void OnDeployed(BaseEntity ent, BasePlayer player)
{
	if (player.IsValid() && !string.IsNullOrEmpty(UnlockAchievement))
	{
		player.GiveAchievement(UnlockAchievement);
	}
	if (ent is BuildingPrivlidge buildingPrivlidge)
	{
		if (Interface.CallHook("OnCupboardAuthorize", local0, player) != null)
		{
			return;
		}
		buildingPrivlidge.AddPlayer(player, player.userID);
	}
}

Injection point 2

Rust.opj (Oxide)
void VehiclePrivilege.AddSelfAuthorize(BaseEntity.RPCMessage)

Passes: VehiclePrivilege vehiclePrivilege, BasePlayer player

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0.player)Assembly-CSharp.dll

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

[RPC_Server]
[RPC_Server.MaxDistance(3f)]
private void AddSelfAuthorize(RPCMessage rpc)
{
	if (rpc.player.CanInteract() && CanModifyAuth(rpc.player))
	{
		if (Interface.CallHook("OnCupboardAuthorize", this, rpc.player) != null)
		{
			return;
		}
		AddPlayer(rpc.player);
		SendNetworkUpdate();
	}
}

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.