{"name":"onPlayerDisconnected","operator":null,"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","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":true},"exec":null,"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","since":null,"effect":null,"exec":null,"params":[{"name":"code","type":"String or Code","optional":false,"default":null,"description":"code executed. The code will receive a number of special variables:\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.","types":["String","Code"],"since":null,"text":"code: String or Code - code executed. The code will receive a number of special variables:\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."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"code","types":["String","Code"]}}],"examples":[{"text":"```sqf\nonPlayerDisconnected {diag_log [_id, _uid, _name]};\n```","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.","problems":null,"aliases":[],"see_also":["onPlayerConnected","didJIP","didJIPOwner","Arma 3: Mission Event Handlers"],"notes":[],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Event Handlers","Command Group: Multiplayer","Introduced with Armed Assault version 1.00","Scripting Commands","Scripting Commands: Server Execution","Take On Helicopters: Scripting Commands"]}