isPlayer: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "[[Category:Scripting Commands ArmA|" to "[[Category:Scripting Commands Armed Assault|")
No edit summary
 
(48 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


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


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


|arg= global |Multiplayer Arguments=
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| Checks if given person is [[player]]. Returns [[true]] for headless clients as well.<br><br>
|game4= tkoh
{{warning | In some cases, the identity of certain player units might fail to propagate to other clients and the server, which causes [[isPlayer]] and [[getPlayerUID]] to incorrectly return <tt>[[false]]</tt> and <tt>""</tt>, respectively, where the affected units are [[not]] [[local]].<ref>https://github.com/michail-nikolaev/task-force-arma-3-radio/issues/1096</ref> Therefore, beware of false negatives.}} |DESCRIPTION=
|version4= 1.00
____________________________________________________________________________________________


| '''isPlayer''' person |SYNTAX=
|game5= arma3
|version5= 0.50


|p1= person: [[Object]] |PARAMETER1=
|gr1= Multiplayer


| [[Boolean]] |RETURNVALUE=
|arg= global
____________________________________________________________________________________________


|x1= <code>[[if]] ([[isPlayer]] _Soldier1) [[then]] {
|descr= Checks if given person is a [[player]]. Returns [[true]] for headless clients as well.
    _Soldier1 [[setDamage]] 1;
};</code> |EXAMPLE1=


|x2= <code>_playerCount = {[[isPlayer]] _x} [[count]] [[playableUnits]];</code> |EXAMPLE2=
{{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.}}
____________________________________________________________________________________________


| [[player]], [[playableSlotsNumber]], [[playableUnits]], [[playersNumber]] |SEEALSO=
{{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


<h3 style="display:none">Notes</h3>
|x1= <sqf>
<dl class="command_description">
if (isPlayer _Soldier1) then
<!-- Note Section BEGIN -->
{
_soldier1 setDamage 1;
};
</sqf>


<dd class="notedate">Posted on 1 August, 2006
|x2= <sqf>_playerCount = { isPlayer _x } count playableUnits;</sqf>
<dt class="note">[[User:Kronzky|Kronzky]]
<dd class="note">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 -->
|x3= <sqf>private _wasPlayer = isPlayer [_deadBody]; // returns true if _deadBody's identity still exists and was controlled by a player</sqf>
</dl>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[player]] [[playableSlotsNumber]] [[playableUnits]] [[playersNumber]]
[[Category:Scripting Commands|ISPLAYER]]
}}
[[Category:Scripting Commands Armed Assault|ISPLAYER]]
 
[[Category:Command_Group:_Object_Information|{{uc:{{PAGENAME}}}}]]
{{Note
[[Category:Command_Group:_Multiplayer|{{uc:{{PAGENAME}}}}]]
|user= Kronzky
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
|timestamp= 20060801
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
|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.
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
}}

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.