PlayerQuit: Difference between revisions
No edit summary |
(Fixed some English, and updated border around Example) |
||
| Line 1: | Line 1: | ||
This event is triggered when a player | This event is triggered when a player quits the server. | ||
==Parameters== | ==Parameters== | ||
* '''player''' - player, which quit from the server | * '''player''' - player, which quit from the server | ||
* '''exitType ''' - exit | * '''exitType ''' - exit types: | ||
**''disconnect'' | **''disconnect'' | ||
**''timeout'' | **''timeout'' | ||
**''kicked'' | **''kicked'' | ||
* '''reason''' - reason | * '''reason''' - kick reason | ||
==Example== | ==Example== | ||
This example outputs chat message, when player quits or kicked from the server. | This example outputs chat message, when player quits or kicked from the server. | ||
<div class="header" style="background-color: # | <div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;"> | ||
<div style="margin: | <div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div> | ||
<syntaxhighlight lang="javascript" style="width: 98%; background-color: #E4F1FE;"> | <syntaxhighlight lang="javascript" style="width: 98%; background-color: #E4F1FE;"> | ||
function playerQuitHandler(player, exitType, reason) { | function playerQuitHandler(player, exitType, reason) { | ||
Revision as of 20:03, 18 September 2017
This event is triggered when a player quits the server.
Parameters
- player - player, which quit from the server
- exitType - exit types:
- disconnect
- timeout
- kicked
- reason - kick reason
Example
This example outputs chat message, when player quits or kicked from the server.
Server-Side
function playerQuitHandler(player, exitType, reason) {
if (exitType != "kicked") {
var str = player.name + " quit.";
} else {
var str = player.name + " kicked. Reason: " + reason + ".";
}
console.log(str);
}
mp.events.add("playerQuit", playerQuitHandler);