RustTip

OnPlayerViolation

OxideCarbonPlayer

Called when player violation occurs.

object OnPlayerViolation(BasePlayer ply, AntiHackType type, float amount, GameObject gameObject)
Works — the game method in this build is the one the hook was written for.

Parameters

ply
BasePlayer
type
AntiHackType
amount
float
gameObject
GameObject

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 OnPlayerViolation(BasePlayer ply, AntiHackType type, float amount, GameObject gameObject)
{
    Puts("OnPlayerViolation");

    // 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 AntiHack.AddViolation(BasePlayer, AntiHackType, float, GameObject)

Passes: BasePlayer ply, AntiHackType type, float amount, GameObject gameObject

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: JustParamsAssembly-CSharp.dll

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

public static void AddViolation(BasePlayer ply, AntiHackType type, float amount, GameObject gameObject = null)
{
	if (Interface.CallHook("OnPlayerViolation", ply, type, amount, gameObject) != null)
	{
		return;
	}
	if (ply.ActivePlayerInd == -1)
	{
		return;
	}
	using (TimeWarning.New("AntiHack.AddViolation"))
// …

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.