OnPlayerQuit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[player]] that left the server.
The [[event system#Event source|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
<syntaxhighlight lang="lua">
-- we register quitPlayer as a handler for the event
function quitPlayer ( )
-- we store the player's name
local quittingPlayerName = getClientName ( source )
-- and send him a greeting
outputChatBox ( quittingPlayerName .. " has left the server" )
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )
</syntaxhighlight>


==See Also==
==See Also==
{{Event_functions}}
{{Event_functions}}
[[Category:Needs Example]]
[[Category:Incomplete]]
[[Category:Incomplete]]

Revision as of 11:06, 5 January 2008

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

Parameters

string reason
  • reason: A string containing the reason why the player left.

Quit reason string can be: - "Unknown" - "Quit" - "Kicked" - "Banned" - "Bad Connection" - "Timed out"

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 ( )
	-- we store the player's name
	local quittingPlayerName = getClientName ( source )
	-- and send him a greeting
	outputChatBox ( quittingPlayerName .. " has left the server" )
end
addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer )

See Also