Difference between revisions of "getPlayerUID"

From Bohemia Interactive Community
Jump to navigation Jump to search
m
m (typo)
 
(28 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{Command|= Comments
+
{{Command|Comments=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| arma2 |= Game name
+
| arma2 |Game name=
  
|1.02|= Game version
+
|1.02|Game version=
____________________________________________________________________________________________
 
  
| Return an uniqueID of the given unit as string if it's player and empty value if it's AI. |= Description
+
|arg= global |Multiplayer Arguments=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| '''getPlayerUID''' unit |= Syntax
+
| Return a UniqueID of the given unit (player).
  
|p1= unit: [[Object]] |= PARAMETER1
+
{{Important|Up until [[{{arma2oa}}]] v1.60, the result always consisted of a [[str|stringified]] number (see [[getPlayerUIDOld]]), but always had to be considered and processed as a [[String]].<!--
 +
--> Converting it to a [[Number]] could cause precision problems, as [[Number]] cannot accurately represent integers above 16777216 (2<sup>24</sup>).<!--
 +
--> Moreover, games since [[{{arma2oa}}]] v1.61 provide a value that is not all-numeric.}}
  
|p2= |= PARAMETER2
+
{{Feature arma3|The returned string is the player's steamID64:
 +
<code>[[private]] _steamProfileUrl {{=}} "http://<nowiki/>steamcommunity.com/profiles/" + ([[getPlayerUID]] [[player]]);</code>}} |DESCRIPTION=
  
|p3= |= PARAMETER3
+
|pr= 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]] - see [https://github.com/michail-nikolaev/task-force-arma-3-radio/issues/1096 this bug report (GitHub)].
 +
Therefore, beware of false negatives. |PROBLEMS=
 +
____________________________________________________________________________________________
  
| [[String]] |= RETURNVALUE
+
| [[getPlayerUID]] unit |SYNTAX=
  
 +
|p1= unit: [[Object]] |PARAMETER1=
  
|x1= <code>_uid <nowiki>=</nowiki> '''getPlayerUID''' [[vehicle]] [[player]];</code> |= Example 1
+
| [[String]] "_SP_AI_" or "_SP_PLAYER_" in SP, "" or UID in MP.<br>
 +
The unique ID may be up to 100 characters long and may contain numbers, uppercase letters and underscores.<br>
 +
The value can be used to construct a valid variable name by appending to another valid variable name,<br>
 +
e.g {{Inline code|[[missionNamespace]] [[setVariable]] ["TAG_player" + _uid, _unit];}} |RETURNVALUE=
  
 +
|x1= <code>[[private]] _uid = [[getPlayerUID]] [[player]];</code> |EXAMPLE1=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| |= SEEALSO  
+
| [[BIS_fnc_getUnitByUID]], [[getPlayerUIDOld]], [[getClientState]], [[getClientStateNumber]] |SEEALSO=  
 
 
|mp= UID string is returned only in multiplayer.  |= MPBEHAVIOUR
 
____________________________________________________________________________________________
 
 
}}
 
}}
  
Line 39: Line 47:
  
 
<h3 style='display:none'>Bottom Section</h3>
 
<h3 style='display:none'>Bottom Section</h3>
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
+
 
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
+
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
+
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
 +
[[Category:Command Group: Multiplayer|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:16, 9 July 2020

Introduced with Arma 2 version 1.021.02Arguments of this scripting command don't have to be local to the client the command is executed on
Hover & click on the images for descriptions

Description

Description:
Return a UniqueID of the given unit (player).
Up until Arma 2: Operation Arrowhead v1.60, the result always consisted of a stringified number (see getPlayerUIDOld), but always had to be considered and processed as a String. Converting it to a Number could cause precision problems, as Number cannot accurately represent integers above 16777216 (224). Moreover, games since Arma 2: Operation Arrowhead v1.61 provide a value that is not all-numeric.
Arma 3 logo black.png
The returned string is the player's steamID64: private _steamProfileUrl = "http://steamcommunity.com/profiles/" + (getPlayerUID player);
Problem(s):
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 false and "" respectively, where the affected units are not local - see this bug report (GitHub). Therefore, beware of false negatives.

Syntax

Syntax:
getPlayerUID unit
Parameters:
unit: Object
Return Value:
String "_SP_AI_" or "_SP_PLAYER_" in SP, "" or UID in MP.
The unique ID may be up to 100 characters long and may contain numbers, uppercase letters and underscores.
The value can be used to construct a valid variable name by appending to another valid variable name,
e.g missionNamespace setVariable ["TAG_player" + _uid, _unit];

Examples

Example 1:
private _uid = getPlayerUID player;

Additional Information

See also:
BIS_fnc_getUnitByUIDgetPlayerUIDOldgetClientStategetClientStateNumber

Notes

i
Only post proven facts here. Report bugs on the feedback tracker and discuss on the Arma Discord or on the Forums.

Notes

Bottom Section