From SA-MP Wiki

Jump to: navigation, search


This callback is called when a player disconnects from the server.

(playerid, reason)
playeridThe ID of the player that disconnected.
reasonThe reason for the disconnection. See table below.

Return Values:

  • 0 - Will prevent other filterscripts from receiving this callback.
  • 1 - Indicates that this callback will be passed to the next filterscript.
  • It is always called first in filterscripts.



Some functions might not work correctly when used in this callback because the player is already disconnected when the callback is called. This means that you can't get unambiguous information from functions like GetPlayerIp and GetPlayerPos.


ID Reason Details
0 Timeout/Crash The player's connection was lost. Either their game crashed or their network had a fault.
1 Quit The player purposefully quit, either using the /quit (/q) command or via the pause menu.
2 Kick/Ban The player was kicked or banned by the server.

Example Usage:

public OnPlayerDisconnect(playerid, reason)
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    new szDisconnectReason[3][] =
    format(szString, sizeof szString, "%s left the server (%s).", playerName, szDisconnectReason[reason]);
    SendClientMessageToAll(0xC4C4C4FF, szString);
    return 1;

Related Callbacks

The following callbacks might be useful as well, as they are related to this callback in one way or another.

Personal tools