{"name":"isPlayer","title":"isPlayer","type":"command","url":"https://community.bistudio.com/wiki/isPlayer","revid":363376,"updated":"2024-03-29T08:30:20Z","groups":["Multiplayer"],"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":{"argument":"global"},"description":"Checks if given person is a player. Returns true for headless clients as well.\n\n> [!NOTE]\n> Prior to Arma 3 v2.02, in some cases the identity of certain player units could fail to propagate to other clients and the server, which caused isPlayer and getPlayerUID to incorrectly return `false` and `\"\"` respectively, where the affected units were not local. See [this GitHub bug report](https://github.com/michail-nikolaev/task-force-arma-3-radio/issues/1096) for more info. Remain vigilant toward potential false negatives.\n\n> [!IMPORTANT]\n> When used on vehicles, this command will return true if effectiveCommander of the vehicle is player. Just because it returns true does not automatically mean we have a player unit. Unlike main syntax, alternative syntax always returns false when used on vehicles, even if they're controlled by a player.","syntaxes":[{"syntax":"isPlayer unit","params":[{"name":"unit","type":"Object","type_expr":"Object"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"unary","right":{"text":"unit"}},{"syntax":"isPlayer [person]","since":"arma3 2.06","params":[{"name":"person","type":"Object","description":"dead or alive unit","type_expr":"Object"}],"returns":{"type":"Boolean","type_expr":"Boolean","description":"true if is/was player and the identity still exists on the (dead) body","text":"Boolean - true if is/was player **and** the identity still exists on the (dead) body"},"form":"unary","right":{"text":"[person]"}}],"examples":[{"text":"```sqf\nif (isPlayer _Soldier1) then\n{\n    _soldier1 setDamage 1;\n};\n```","code":["if (isPlayer _Soldier1) then\n{\n\t_soldier1 setDamage 1;\n};"]},{"code":["_playerCount = { isPlayer _x } count playableUnits;"]},{"code":["private _wasPlayer = isPlayer [_deadBody]; // returns true if _deadBody's identity still exists and was controlled by a player"]}],"see_also":["player","playableSlotsNumber","playableUnits","playersNumber"],"notes":[{"user":"Kronzky","text":"This is not the same as testing object == player, because in MP it tests for any player, not only for the local one. If object is a vehicle, the test is done for the vehicle commander."}]}