OnUserDisconnected
OxideCarbonPlayerCalled when an user disconnects.
void OnUserDisconnected(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 OnUserDisconnected(Oxide.Core.Libraries.Covalence.IPlayer player, string reason)
{
Puts("OnUserDisconnected");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Where it is called
Oxide core (Oxide.Rust)
RustCore::OnPlayerDisconnected(BasePlayer basePlayer, string reason)
Oxide core code — the hook is called from here
private void OnPlayerDisconnected(BasePlayer basePlayer, string reason)
{
IPlayer player = basePlayer.IPlayer;
if (player != null)
{
Interface.CallHook("OnUserDisconnected", player, reason);
}
Covalence.PlayerManager.PlayerDisconnected(basePlayer);
}Injection point
Rust.opj (Oxide)
void ServerMgr.OnDisconnected(string, Network.Connection)
Injected internal hook OnPlayerDisconnected — this hook is called by its handler in the Oxide/Carbon core
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l0, a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (connection.authStatusSteam == "ok")
{
PlatformService.Instance.EndPlayerSession(connection.userid);
}
EACServer.OnLeaveGame(connection);
BasePlayer basePlayer = connection.player as BasePlayer;
if (basePlayer != null)
{
Interface.CallHook("OnPlayerDisconnected", basePlayer, strReason);
basePlayer.OnDisconnected();
}
if (connection.authStatusNexus == "ok")
{
NexusServer.Logout(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.