OnPlayerQuit
onPlayerQuit
IMPROVED FROM UPDATE 0.1.2
This event is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.
Triggered synchronously while an authenticated player's disconnect is being finalized.
Availability
This event is available in server-side scripts.
Callback signature
onPlayerQuit(playerId)
Parameters
| Name | Type | Description |
|---|---|---|
playerId |
int |
The ID of the player that left. |
Examples
Handle the event:
addEventHandler("onPlayerQuit", root, function(playerId)
outputDebugString("Player " .. playerId .. " left")
end)
Notes
- The player is already offline for lifecycle and mutation purposes:
isPlayerConnected(playerId)returnsfalse,getPlayers()excludes the ID, and player mutators reject it. - Read-only getters backed by cached authoritative player state remain available only while synchronous
onPlayerQuithandlers are running. Read and persist every required final value before the callback returns; deferred work cannot query the removed session. - Use this event to save final authoritative state and clean up player-owned script data, but do not rely on it as the only crash-safety mechanism. No quit callback is guaranteed if the server process ends in a hard crash or forced termination.