OnClientPlayerQuit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client event}}
{{Client event}}
This event is triggered when a remote player quits the game or leaves the server.
This event is triggered when a '''remote''' player quits the game or leaves the server. It '''will not''' get triggered on the source player's client. (Use [[onClientResourceStop]] to save client side data when the local player quits.)


==Parameters==
==Parameters==
Line 9: Line 9:


*'''reason''': A string representing the reason why the player quit.
*'''reason''': A string representing the reason why the player quit.
 
** "Unknown"
Quit reason string can be:
** "Quit"
- "Unknown"
** "Kicked"
- "Quit"
** "Banned"
- "Kicked"
** "Bad Connection"
- "Banned"
** "Timed out"
- "Bad Connection"
- "Timed out"


==Source==
==Source==
Line 22: Line 20:


==Example==  
==Example==  
This example prints a message in server window when player leaves the server.
This example prints a message in the chatbox when a remote player leaves the server.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onQuitGame( reason )
function onQuitGame( reason )
     print( getPlayerName( getLocalPlayer() ).." has left the server ("..reason..")" )
     outputChatBox ( getPlayerName( source ).." has left the server ("..reason..")" )
end
end
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )

Latest revision as of 17:15, 23 August 2014

This event is triggered when a remote player quits the game or leaves the server. It will not get triggered on the source player's client. (Use onClientResourceStop to save client side data when the local player quits.)

Parameters

string reason
  • reason: A string representing the reason why the player quit.
    • "Unknown"
    • "Quit"
    • "Kicked"
    • "Banned"
    • "Bad Connection"
    • "Timed out"

Source

The source of this event is the player that quit the game.

Example

This example prints a message in the chatbox when a remote player leaves the server.

function onQuitGame( reason )
    outputChatBox ( getPlayerName( source ).." has left the server ("..reason..")" )
end
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame )

See Also

Client player events


Client event functions