RustTip

OnUserKicked

OxideCarbonPlayer

Called when an user is kicked.

void OnUserKicked(Oxide.Core.Libraries.Covalence.IPlayer player, string reason)
Works — the game method in this build is the one the hook was written for.

Parameters

player
Oxide.Core.Libraries.Covalence.IPlayer
reason
string

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnUserKicked(Oxide.Core.Libraries.Covalence.IPlayer player, string reason)
{
    Puts("OnUserKicked");
}

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

Where it is called

Oxide core (Oxide.Rust)
RustCore::OnPlayerKicked(BasePlayer basePlayer, string reason)

Oxide core code — the hook is called from here

private void OnPlayerKicked(BasePlayer basePlayer, string reason)
{
    IPlayer player = basePlayer.IPlayer;
    if (player != null)
    {
        Interface.CallHook("OnUserKicked", basePlayer.IPlayer, reason);
    }
}

Injection point 1

Rust.opj (Oxide)
void BasePlayer.Kick(string, bool)

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

WorksReturnBehavior: ContinueArgumentBehavior: AllAssembly-CSharp.dll

Injection point 2

Rust.opj (Oxide)
void EACServer.OnClientActionRequired(ref Epic.OnlineServices.AntiCheatCommon.OnClientActionRequiredCallbackInfo)

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

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l2, l3.ToString())Assembly-CSharp.dll

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

// …
if (connection.IsDevelopmentBuild())
{
	Debug.LogWarning("[EAC] Remove player action skipped for unprotected client: " + connection.ToString());
	return;
}
Debug.Log($"[EAC] Kicking {connection.userid} / {connection.username} ({actionReasonDetailsString})");
connection.authStatusEAC = "eac";
Network.Net.sv.Kick(connection, "EAC: " + actionReasonDetailsString);
Interface.CallHook("OnPlayerKicked", connection, actionReasonDetailsString.ToString());
if (data.ActionReasonCode == AntiCheatCommonClientActionReason.PermanentBanned || data.ActionReasonCode == AntiCheatCommonClientActionReason.TemporaryBanned)
{
	connection.authStatusEAC = "eacbanned";
	ConsoleNetwork.BroadcastToAllClients("chat.add", 2, 0, "<color=#fff>SERVER</color> Kicking " + connection.username + " (banned by anticheat)");
	if (data.ActionReasonCode == AntiCheatCommonClientActionReason.PermanentBanned)
	{
		Entity.DeleteBy(connection.userid);
	}
// …

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.