PlayerQuit

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

This event is triggered when a player quits/disconnects/leaves the server.

Server-Side
Event

C.png C# Js.png JavaScript




C# Syntax
C.png


JavaScript Syntax
Jslogo.png

Parameters

  • player: Player - player, which quit from the server
  • exitType: String - exit types:
    • disconnect
    • timeout
    • kicked
  • reason: String - kick reason

Example

This example outputs chat message, when player quits or kicked from the server.

function playerQuitHandler(player, exitType, reason) {
  let str = player.name;

  if (exitType != "kicked") {
    str += " quit.";
  } else {
    str = ` kicked. Reason: ${reason}.`;
  }

  console.log(str);
}

mp.events.add("playerQuit", playerQuitHandler);


Client-Side Event

C.png C# Js.png JavaScript



C# Syntax
C.png

public delegate void OnPlayerQuitDelegate(Player player);

Parameters

  • player: The player leaving the server, expects RAGE.Elements.Player type.

Example

The example below shows up a message to the client when another player leaves the server.

Events.OnPlayerQuit += OnPlayerQuit;
public void OnPlayerQuit(RAGE.Elements.Player player)
{
    RAGE.Chat.Output($"Player {player.Name} has left");
}


JavaScript Syntax
Jslogo.png

Parameters

  • player: Player - the other player who left the server

Example

This example displays a notification for the player, when another player disconnected from server.

mp.events.add("playerQuit", (player) => {
    mp.game.graphics.notify(`<C>${player.name}</C> (ID:${player.remoteId}) left the server`);
});


See also

Checkpoint

Colshape

Entity

Player

Streaming

Vehicle

Waypoint