OnCounterModeToggle
OxideCarbonElectronicCalled when a counter mode toggles.
object OnCounterModeToggle(object arg0)Works — the game method in this build is the one the hook was written for.
Parameters
- arg0
- object
Return value
objectThe result is checked in a special way — see the call code below.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnCounterModeToggle(object arg0)
{
Puts("OnCounterModeToggle");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void PowerCounter.ToggleDisplayMode(BaseEntity.RPCMessage)
Passes: object arg0
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.IsVisible(3f)]
public void ToggleDisplayMode(RPCMessage msg)
{
object result = Interface.CallHook("OnCounterModeToggle", msg.read.Bit());
// … проверка результата (Modify-хук, см. Rust.opj)
if (msg.player.CanBuild())
{
SetFlagLocal(Flags.Reserved3, msg.read.Bit());
MarkDirty();
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.