{"name":"onPlayerDisconnected","title":"onPlayerDisconnected","type":"command","url":"https://community.bistudio.com/wiki/onPlayerDisconnected","revid":369204,"updated":"2024-09-03T10:34:50Z","groups":["Multiplayer","Event Handlers"],"status":"ok","games":{"arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma1 1.00","arma3_since":"0.50","locality":{"server_exec":true},"description":"This command will execute attached code whenever a player is leaving an MP session. The code will receive a number of special variables:","syntaxes":[{"syntax":"onPlayerDisconnected code","params":[{"name":"code","type":"String or Code","description":"code executed. The code will receive a number of special variables:\n\n- _id: Number - 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.\n- _uid: String - Is getPlayerUID of the leaving player. In Arma 3 it is also the same as Steam ID.\n- _name: String - Is profileName of the leaving player.\n- Arma 3 v1.50 _jip: Boolean - Is a flag that indicated whether or not the player joined after the mission has started (**J**oined **I**n **P**rogress). true - if the player was JIP, otherwise false.\n- Arma 3 v1.50 _owner: Number - Is owner id of the leaving player. Can be used for kick or ban purposes or just for publicVariableClient.\n- Arma 3 v1.96 _idstr: String - Same as `_id` but in string format, so could be exactly compared to user marker ids.","type_expr":"String | Code"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"code"}}],"examples":[{"code":["onPlayerDisconnected {diag_log [_id, _uid, _name]};"]},{"text":"```sqf\nonPlayerDisconnected {\n    if (count allPlayers == 0) then {\n        endMission \"END1\";\n    };\n};\n```","code":["onPlayerDisconnected {\n\tif (count allPlayers == 0) then {\n\t\tendMission \"END1\";\n\t};\n};"]}],"multiplayer":"In multiplayer onPlayerDisconnected is executed only on the server.\n\n> [!NOTE]\n> **Arma 3:** Use playerDisconnected or HandleDisconnect instead in Arma 3.","see_also":["onPlayerConnected","didJIP","didJIPOwner","Arma 3: Mission Event Handlers"]}