isPlayer: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(79 intermediate revisions by 17 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= arma1
|version1= 1.00


|2.92|= Game version
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Check if given person is a human player.  |= Description
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| '''isPlayer''' person |= Syntax
|game4= tkoh
|version4= 1.00


|p1= person: [[Object]] |= Parameter 1
|game5= arma3
|version5= 0.50


| [[Boolean]] |= Return value
|gr1= Multiplayer
____________________________________________________________________________________________


| |= See also
|arg= global


|descr= Checks if given person is a [[player]]. Returns [[true]] for headless clients as well.
{{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.}}
{{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.}}
|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]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Kronzky
<!-- Note Section BEGIN -->
|timestamp= 20060801
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.
|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.
<!-- Note Section END -->
}}
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|ISPLAYER]]
[[Category:Scripting Commands ArmA|ISPLAYER]]

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.