{"name":"isPlayer","operator":null,"title":"isPlayer","type":"command","url":"https://community.bistudio.com/wiki/isPlayer","revid":363376,"updated":"2024-03-29T08:30:20Z","groups":["Multiplayer"],"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":"global","effect":null,"server_exec":false},"exec":null,"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","since":null,"effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"unit: Object"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"unary","operator":null,"left":null,"right":{"text":"unit","types":["Object"]}},{"syntax":"isPlayer [person]","since":"arma3 2.06","effect":null,"exec":null,"params":[{"name":"person","type":"Object","optional":false,"default":null,"description":"dead or alive unit","types":["Object"],"since":null,"text":"person: Object - dead or alive unit"}],"returns":{"type":"Boolean","types":["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","operator":null,"left":null,"right":{"text":"[person]","types":["Array"]}}],"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};"]},{"text":"```sqf\n_playerCount = { isPlayer _x } count playableUnits;\n```","code":["_playerCount = { isPlayer _x } count playableUnits;"]},{"text":"```sqf\nprivate _wasPlayer = isPlayer [_deadBody]; // returns true if _deadBody's identity still exists and was controlled by a player\n```","code":["private _wasPlayer = isPlayer [_deadBody]; // returns true if _deadBody's identity still exists and was controlled by a player"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["player","playableSlotsNumber","playableUnits","playersNumber"],"notes":[{"user":"Kronzky","date":"","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."}],"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: Multiplayer","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}