OnCupboardAssign
OxideCarbonStructureCalled when cupboard assign occurs.
object OnCupboardAssign(BuildingPrivlidge priv, ulong targetId, BasePlayer player)Works — the game method in this build is the one the hook was written for.
Parameters
- priv
- BuildingPrivlidge
- targetId
- ulong
- 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 OnCupboardAssign(BuildingPrivlidge priv, ulong targetId, BasePlayer player)
{
Puts("OnCupboardAssign");
// 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
// …
{
if (userID == player.userID)
{
if (Interface.CallHook("OnCupboardAuthorize", privlidge, player) != null)
{
return true;
}
}
else if (Interface.CallHook("OnCupboardAssign", privlidge, userID, player) != null)
{
return true;
}
return null;
}Injection point
Rust.opj (Oxide)
void BuildingPrivlidge.AddAuthorize(BaseEntity.RPCMessage)
Injected internal hook IOnCupboardAuthorize — this hook is called by its handler in the Oxide/Carbon core
WorksReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (l0, a0.player, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.IsVisible(3f)]
private void AddAuthorize(RPCMessage rpc)
{
if (rpc.player.CanInteract() && CanAdministrate(rpc.player))
{
ulong targetPlayerId = rpc.read.UInt64();
if (Interface.CallHook("IOnCupboardAuthorize", targetPlayerId, rpc.player, this) != null)
{
return;
}
AddPlayer(rpc.player, targetPlayerId);
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.