OnPlayerQuit: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
void | void onPlayerQuit ( string reason ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Example== | ==Example== | ||
This example | This example destroys the blips attached to a player and removes him from his team when he quits. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onPlayerQuit () -- When the player quits | |||
function onPlayerQuit () --When the player quits | destroyBlipsAttachedTo ( source ) -- Destroy his blips | ||
destroyBlipsAttachedTo ( source ) -- | removePlayerFromTeam ( source ) -- And remove him from the team he was in | ||
removePlayerFromTeam ( source ) -- | |||
end | end | ||
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) -- | addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) -- Tell MTA to call above function when the event occurs | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 16:12, 14 September 2007
This event is triggered when a player leaves the game, for whatever reason.
Syntax
void onPlayerQuit ( string reason )
Example
This example destroys the blips attached to a player and removes him from his team when he quits.
function onPlayerQuit () -- When the player quits destroyBlipsAttachedTo ( source ) -- Destroy his blips removePlayerFromTeam ( source ) -- And remove him from the team he was in end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) -- Tell MTA to call above function when the event occurs