OnPlayerDisconnect
From SA-MP Wiki
OnPlayerDisconnect
This callback is called when a player disconnects from the server.
(playerid, reason)
| playerid | ID of the player who left. |
| reason | ID of the reason why they left. |
This function does not return a specific value, it's best to simply ignore it.
Examples of making a text message to all of the reason player disconnects (since the native messages were taken out in 0.2.)
public OnPlayerDisconnect(playerid, reason) { new string[64], name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); switch(reason) { case 0: format(string,sizeof string,"%s left the server. (Timed out)",name); case 1: format(string,sizeof string,"%s left the server. (Leaving)",name); case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name); } SendClientMessageToAll(0xFFFFFFAA,string); return 1; }
Reasons
- 0 Timed out
- 1 Left normally (/q or ESC menu and quit)
- 2 Kicked or banned
Related Callbacks
The following callbacks might be useful as well, as they're related to this callback in one way or another.
- OnPlayerConnect: Called when a player connects to the server.
