OnPlayerQuit: Difference between revisions
Jump to navigation
Jump to search
m (→Parameters) |
m (→Example) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 9: | Line 9: | ||
*'''quitType''': How the player left. Possible values: | *'''quitType''': How the player left. Possible values: | ||
** Unknown | **''"Unknown"'' | ||
** Quit | **''"Quit"'' | ||
** Kicked | **''"Kicked"'' | ||
** Banned | **''"Banned"'' | ||
** 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. | *'''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. | ||
Line 21: | Line 21: | ||
==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. | ||
==Cancel effect== | |||
This event cannot be canceled. | |||
==Example== | ==Example== | ||
This example gets | This example gets a quitting player's name and outputs that they left the server. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- we register quitPlayer as a handler for the event | -- we register quitPlayer as a handler for the event | ||
function | addEventHandler("onPlayerQuit", root, | ||
function(quitType) | |||
outputChatBox(getPlayerName(source).." has left the server ("..quitType..")") | |||
end | end | ||
) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Player events}} | {{See also/Server event|Player events}} |
Latest revision as of 13:14, 25 January 2024
This event is triggered when a player disconnects from the server.
Parameters
string quitType, string reason, element responsibleElement
- quitType: How the player left. Possible values:
- "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.
- responsibleElement: The element that was responsible for kicking or banning the player. This is commonly another player, but can also be the console element.
Source
The source of this event is the player that left the server.
Cancel effect
This event cannot be canceled.
Example
This example gets a quitting player's name and outputs that they left the server.
-- we register quitPlayer as a handler for the event addEventHandler("onPlayerQuit", root, function(quitType) outputChatBox(getPlayerName(source).." has left the server ("..quitType..")") end )
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled