RustTip

OnUserBanned

OxideCarbonPlayer

Called when an user is banned.

void OnUserBanned(string playerName, string playerId, string address, string reason, long expiry)
Works — the game method in this build is the one the hook was written for.

Parameters

playerName
string
playerId
string
address
string
reason
string
expiry
long

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnUserBanned(string playerName, string playerId, string address, string reason, long expiry)
{
    Puts("OnUserBanned");
}

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

Where it is called

Oxide core (Oxide.Rust)
RustCore::OnServerUserSet(ulong steamId, ServerUsers.UserGroup group, string playerName, string reason, long expiry)

Oxide core code — the hook is called from here

private void OnServerUserSet(ulong steamId, ServerUsers.UserGroup group, string playerName, string reason, long expiry)
{
    if (serverInitialized && group == ServerUsers.UserGroup.Banned)
    {
        string playerId = steamId.ToString();
        IPlayer player = Covalence.PlayerManager.FindPlayerById(playerId);
        Interface.CallHook("OnPlayerBanned", playerName, steamId, player?.Address ?? "0", reason, expiry);
        Interface.CallHook("OnUserBanned", playerName, playerId, player?.Address ?? "0", reason, expiry);
    }
}

Injection point

Rust.opj (Oxide)
void ServerUsers.Set(ulong, ServerUsers.UserGroup, string, string, long)

Injected internal hook OnServerUserSet — this hook is called by its handler in the Oxide/Carbon core

WorksReturnBehavior: ContinueArgumentBehavior: JustParamsAssembly-CSharp.dll

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

// …
	User value = new User
	{
		steamid = uid,
		group = group,
		username = username,
		notes = notes,
		expiry = expiry
	};
	Interface.CallHook("OnServerUserSet", uid, group, username, notes, expiry);
	users.Add(uid, value);
}

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.