PlayerQuit
This event is triggered when a player quits/disconnects/leaves the server.
Server-Side Event
C# | JavaScript |
---|
C# Syntax
[ServerEvent(Event.PlayerDisconnected)]
Parameters
- player: parameter input should be in Player type
- type: parameter input should be in DisconnectionType type
- reason: parameter input should be in string type
Example
[ServerEvent(Event.PlayerDisconnected)]
public void OnPlayerDisconnect(Player player, DisconnectionType type, string reason)
{
switch (type)
{
case DisconnectionType.Left:
player.SendChatMessage($"~b~{player.Name}~w~ has quit the server.");
break;
case DisconnectionType.Timeout:
player.SendChatMessage($"~b~{player.Name}~w~ has timed out.");
break;
case DisconnectionType.Kicked:
player.SendChatMessage($"~b~{player.Name}~w~ was kicked from the server {reason}.");
break;
}
}
JavaScript Syntax
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# | JavaScript |
---|
C# Syntax
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
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
- playerChat
- playerCommand
- playerDamage
- playerDeath
- playerJoin
- playerQuit
- playerReady
- playerSpawn
- playerWeaponChange
Streaming
Vehicle
- playerStartEnterVehicle
- playerEnterVehicle
- playerStartExitVehicle
- playerExitVehicle
- trailerAttached
- vehicleDamage
- vehicleDeath
- vehicleHornToggle
- vehicleSirenToggle