isPlayer: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^ ]*)\{\{cc\|([^ ]*)\}\}([^ ]*)<\/code>" to "<code>$1// $2$3</code>")
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)<\/code>" to "<code>$1$2$3 $4 $5 $6</code>")
Line 41: Line 41:
|r2= [[Boolean]] - [[true]] if is/was player  
|r2= [[Boolean]] - [[true]] if is/was player  


|x1= <code>[[if]] ([[isPlayer]] _Soldier1) [[then]]
|x1= <code>if ([[isPlayer]] _Soldier1) [[then]]
{
{
_soldier1 [[setDamage]] 1;
_soldier1 [[setDamage]] 1;

Revision as of 13:48, 12 May 2022

Hover & click on the images for description

Description

Description:
Checks if given person is a player. Returns true for headless clients as well.
While identity still exists on the dead body of a player, the alternative syntax will return true.
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 bug report (GitHub) for more info. This was supposedly fixed, but you should remain vigilant toward false negatives nonetheless.
Groups:
Multiplayer

Syntax

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

Alternative Syntax

Syntax:
isPlayer [person]
Parameters:
[person]: Array
person: Object - dead or alive player
Return Value:
Boolean - true if is/was player

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.