---
name: "onPlayerDisconnected"
type: command
status: ok
groups: ["Multiplayer", "Event Handlers"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": true}
source: https://community.bistudio.com/wiki/onPlayerDisconnected
revid: 369204
updated: 2024-09-03T10:34:50Z
---

# onPlayerDisconnected

*Command · Multiplayer, Event Handlers · Arma 3 v0.50 · introduced in Armed Assault v1.00*

Locality: **server execution only**

## Description

This command will execute attached code whenever a player is leaving an MP session. The code will receive a number of special variables:

## Syntax

```sqf
onPlayerDisconnected code
```

**Parameters:**

- `code`: [String](../topics/String.md) or [Code](../topics/Code.md) - code executed. The code will receive a number of special variables:
  - _id: [Number](../topics/Number.md) - Is the unique DirectPlay ID. Quite useless as the number is too big for in-built string representation and gets rounded. It is also the same id used for user placed markers.
  - _uid: [String](../topics/String.md) - Is [getPlayerUID](../commands/getPlayerUID.md) of the leaving player. In Arma 3 it is also the same as Steam ID.
  - _name: [String](../topics/String.md) - Is [profileName](../commands/profileName.md) of the leaving player.
  - Arma 3 v1.50 _jip: [Boolean](../topics/Boolean.md) - Is a flag that indicated whether or not the player joined after the mission has started (**J**oined **I**n **P**rogress). [true](../commands/true.md) - if the player was JIP, otherwise [false](../commands/false.md).
  - Arma 3 v1.50 _owner: [Number](../topics/Number.md) - Is [owner](../commands/owner.md) id of the leaving player. Can be used for kick or ban purposes or just for [publicVariableClient](../commands/publicVariableClient.md).
  - Arma 3 v1.96 _idstr:  [String](../topics/String.md) - Same as `_id` but in string format, so could be exactly compared to [user marker](../commands/allMapMarkers.md) ids.

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
onPlayerDisconnected {diag_log [_id, _uid, _name]};
```

### Example 2

```sqf
onPlayerDisconnected {
    if (count allPlayers == 0) then {
        endMission "END1";
    };
};
```

## Multiplayer

In multiplayer [onPlayerDisconnected](../commands/onPlayerDisconnected.md) is executed only on the server.

> [!NOTE]
> **Arma 3:** Use [playerDisconnected](../topics/Mission_Event_Handlers.md#playerdisconnected) or [HandleDisconnect](../topics/Mission_Event_Handlers.md#handledisconnect) instead in Arma 3.

## See also

[onPlayerConnected](../commands/onPlayerConnected.md) · [didJIP](../commands/didJIP.md) · [didJIPOwner](../commands/didJIPOwner.md) · [Arma 3: Mission Event Handlers](../topics/Mission_Event_Handlers.md)

<sub>Source: [BI Community Wiki — onPlayerDisconnected](https://community.bistudio.com/wiki/onPlayerDisconnected) (revision 369204).</sub>
