isPlayer: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (the -> a (better))
No edit summary
 
(84 intermediate revisions by 20 users not shown)
Line 1: Line 1:
[[Category:Scripting Commands|ISPLAYER]]
{{RV|type=command
[[Category:Scripting Commands ArmA|ISPLAYER]]


|game1= arma1
|version1= 1.00


<h2 style="color:#000066">''' isPlayer ''person'''''</h2>
|game2= arma2
|version2= 1.00


|game3= arma2oa
|version3= 1.50


'''Operand types:'''
|game4= tkoh
|version4= 1.00


'''person:''' [[Object]]
|game5= arma3
|version5= 0.50


'''Type of returned value:'''
|gr1= Multiplayer


[[Boolean]]
|arg= global


'''Compatibility:'''
|descr= Checks if given person is a [[player]]. Returns [[true]] for headless clients as well.


Version 2.92 required.
{{Feature|informative|Prior to {{arma3}} 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 {{hl|[[false]]}} and {{hl|""}} respectively, where the affected units were [[not]] [[local]]. See {{Link|https://github.com/michail-nikolaev/task-force-arma-3-radio/issues/1096|this GitHub bug report}} for more info. Remain vigilant toward potential false negatives.}}


'''Description:'''
{{Feature|important|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.}}


Check if given person is a human player. It is not the same as testing object == plyaer, because in MP it tests for any player, not only for the local one.
|s1= [[isPlayer]] unit
 
|p1= unit: [[Object]]
 
|r1= [[Boolean]]
 
|s2= [[isPlayer]] [person]
 
|s2since= arma3 2.06
 
|p21= person: [[Object]] - dead or alive unit
 
|r2= [[Boolean]] - [[true]] if is/was player '''and''' the identity still exists on the (dead) body
 
|x1= <sqf>
if (isPlayer _Soldier1) then
{
_soldier1 setDamage 1;
};
</sqf>
 
|x2= <sqf>_playerCount = { isPlayer _x } count playableUnits;</sqf>
 
|x3= <sqf>private _wasPlayer = isPlayer [_deadBody]; // returns true if _deadBody's identity still exists and was controlled by a player</sqf>
 
|seealso= [[player]] [[playableSlotsNumber]] [[playableUnits]] [[playersNumber]]
}}
 
{{Note
|user= Kronzky
|timestamp= 20060801
|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.
}}

Latest revision as of 09:30, 29 March 2024

Hover & click on the images for description

Description

Description:
Checks if given person is a player. Returns true for headless clients as well.
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 for more info. Remain vigilant toward potential false negatives.
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.
Groups:
Multiplayer

Syntax

Syntax:
isPlayer unit
Parameters:
unit: Object
Return Value:
Boolean

Alternative Syntax

Syntax:
isPlayer [person]
Parameters:
person: Object - dead or alive unit
Return Value:
Boolean - true if is/was player and the identity still exists on the (dead) body

Examples

Example 1:
if (isPlayer _Soldier1) then { _soldier1 setDamage 1; };
Example 2:
_playerCount = { isPlayer _x } count playableUnits;
Example 3:
private _wasPlayer = isPlayer [_deadBody]; // returns true if _deadBody's identity still exists and was controlled by a player

Additional Information

See also:
player playableSlotsNumber playableUnits playersNumber

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Kronzky - c
Posted on Aug 01, 2006 - 00:00 (UTC)
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.