OnPlayerQuit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (See Also for server events)
(added kick/ban reason, renamed old reason arg to quitType)
Line 5: Line 5:
==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string reason
string quitType, string reason
</syntaxhighlight>  
</syntaxhighlight>  


*'''reason''': A string containing the reason why the player left.
*'''quitType''': How the player left.
Quit reason string can be:
This argument can be:
- "Unknown"
- "Unknown"
- "Quit"
- "Quit"
Line 16: Line 16:
- "Bad Connection"
- "Bad Connection"
- "Timed out"
- "Timed out"
*'''reason''': If the player was kicked or banned, the reason given goes here. If the player was '''not''' kicked or banned, this will be false.


==Source==
==Source==

Revision as of 15:03, 17 May 2009

This event is triggered when a player disconnects from the server.

Parameters

string quitType, string reason
  • quitType: How the player left.

This argument can be: - "Unknown" - "Quit" - "Kicked" - "Banned" - "Bad Connection" - "Timed out"

  • reason: If the player was kicked or banned, the reason given goes here. If the player was not kicked or banned, this will be false.

Source

The source of this event is the player that left the server.

Example

This example gets the quitting client's name and outputs that he is gone

-- we register quitPlayer as a handler for the event
function quitPlayer ( reason )
	-- we store the player's name
	local quittingPlayerName = getClientName ( source )
	-- and send the message to the server
	outputChatBox ( quittingPlayerName .. " has left the server (" .. reason .. ")" )
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )

See Also

Player events


Event functions