RustTip

OnClientDisconnect

OxideCarbonPlayer

Called when a client disconnects.

void OnClientDisconnect(Network.Connection connection, string local0)
Works — the game method in this build is the one the hook was written for.

Parameters

connection
Network.Connection
local0
string

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnClientDisconnect(Network.Connection connection, string local0)
{
    Puts("OnClientDisconnect");
}

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

Injection point

Rust.opj (Oxide)
void ServerMgr.ReadDisconnectReason(Network.Message)

Passes: Network.Connection connection, string local0

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (a0.connection, l0)Assembly-CSharp.dll

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

public void ReadDisconnectReason(Message packet)
{
	string text = packet.read.String(4096);
	string text2 = packet.connection.ToString();
	if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
	{
		Interface.CallHook("OnClientDisconnect", packet.connection, text);
		DebugEx.Log(text2 + " disconnecting: " + text);
	}
}

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.