PlayerQuit: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Fixed some English, and updated border around Example)
Line 1: Line 1:
This event is triggered when a player quit from the server.
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 type from the server:
* '''exitType ''' - exit types:
**''disconnect''
**''disconnect''
**''timeout''
**''timeout''
**''kicked''
**''kicked''
* '''reason''' - reason of quit from the server if exit type is "kicked".
* '''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: #E4F1FE; color: #4183D7; width: 100%; border: 2px solid #81CFE0;">
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
<div style="margin: 4px 0px 4px 10px;"><b>Server-side</b></div>
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
</div>
<div class="content" style="background-color: #E4F1FE; color: #4183D7; width: 100%; border: 2px solid #81CFE0; display: flex; justify-content: center; align-items: center;">
<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);

See also