OnPlayerDisconnected
From GTA Network Wiki
OnPlayerDisconnectedServer-Side Function
![]() |
![]() |
---|
This type of event is used for handling code when the player disconnects.
Attribute
[ServerEvent(Event.PlayerDisconnected)]
Required Parameters
- Client: the player.
- DisconnectionType: type of the disconnection.
- string: reason if player got kicked or banned.
Usage example(s)
[ServerEvent(Event.PlayerDisconnected)] public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason) { switch (type) { case DisconnectionType.Left: NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has quit the server."); break; case DisconnectionType.Timeout: NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has timed out."); break; case DisconnectionType.Kicked: NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has been kicked for " + reason); break; } }
Changelog
Version | Description |
---|---|
1.0 | Release. |