getAllUnitTraits: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (2.00 update)
m (Some wiki formatting)
 
(18 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command


|game1= arma3 |Game name=
|game1= arma3
|version1= 2.00
<!--
|arg= local
-->
|gr1= Object Manipulation


|version= 2.00 |Game version=
|descr= Returns unit traits (native or set by [[setUnitTrait]]).


|arg= <!-- local, to be confirmed --> |Multiplayer Arguments ("local" or "global")=
|s1= [[getAllUnitTraits]] unit


|eff= |Multiplayer Effects ("local" or "global")=
|p1= unit: [[Object]] or {{GVI|arma3|2.18|size= 0.75}} [[String]] - a unit or a class name


|serverExec= |Multiplayer Execution ("server" or empty)=
|r1= [[Array]] of [[Array]]s in format [name, value] where:
* name: [[String]] - trait's name
* value [[String]] or [[Boolean]] - trait's value


|gr1= Object Manipulation |GROUP1=
|x1= <sqf>
____________________________________________________________________________________________
private _playerTraits = getAllUnitTraits player;
 
/*
|descr= Returns unit traits, native or set by [[setUnitTrait]]. |Description=
Could return something like this:
 
|mp= |Multiplayer Behaviour=
 
|pr= |Problems=
____________________________________________________________________________________________
 
|s1= [[getAllUnitTraits]] unit |Syntax=
 
|p1= unit: [[Object]] |Parameter 1=
 
|r1= [[Array]] of [[Array]]s of [<nowiki/>[[String]], [[String]]/[[Boolean]]] - to format [["traitName1",value1], ["traitName2", value2]] |Return Value=
____________________________________________________________________________________________
 
|x1= <code>{{codecomment|/* can return:
[
[
["Medic", false],
["Medic", false],
Line 39: Line 32:
["test", "custom"]
["test", "custom"]
]
]
<nowiki/>*/}}
*/
[[private]] _playerTraits = [[getAllUnitTraits]] [[player]];</code> |Example 1=
</sqf>
 
|x2= <sqf>
private _unitTraits = getAllUnitTraits _unit;
private _indexes = [_unitTraits, "Medic"] call BIS_fnc_findNestedElement;
private _unitCanHeal = _unitTraits select (_indexes select 0) select 1;
</sqf>


|x2= <code>[[private]] _unitTraits = [[getAllUnitTraits]] _unit;
|x3= Since {{GVI|arma3|2.18|size= 0.75}}:
[[private]] _indexes = [_unitTraits, "Medic"] [[call]] [[BIS_fnc_findNestedElement]];
<sqf>
[[private]] _unitCanHeal = _unitTraits [[select]] (_indexes [[select]] 0) [[select]] 1;</code> |Example 2=
hint str getAllUnitTraits "O_Engineer_F";
____________________________________________________________________________________________
/*
[
["Medic", false],
["Engineer", true],
["ExplosiveSpecialist", true],
["UavHacker", false],
["CamouflageCoef", 1],
["AudibleCoef", 1],
["LoadCoef", 1]
]
*/
</sqf>


|seealso= [[setUnitTrait]] |See Also=
|seealso= [[getUnitTrait]] [[setUnitTrait]]
}}
}}


<dl class="command_description">
{{Note
<!-- BEGIN Note Section -->
|user= BrettMayson
<!-- For example:
|timestamp= 20231127025400
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
|text= Local argument assumed, needs confirmation
<dt class="note">[[User:User Name|User Name]]</dt>
}}
<dd class="note">This is an example note. It is true and verifiable, and contains a little code snippet.
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
-->
<!-- END Note Section -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>

Latest revision as of 01:27, 30 April 2024

Hover & click on the images for description

Description

Description:
Returns unit traits (native or set by setUnitTrait).
Groups:
Object Manipulation

Syntax

Syntax:
getAllUnitTraits unit
Parameters:
unit: Object or Arma 3 logo black.png2.18 String - a unit or a class name
Return Value:
Array of Arrays in format [name, value] where:

Examples

Example 1:
private _playerTraits = getAllUnitTraits player; /* Could return something like this: [ ["Medic", false], ["Engineer", false], ["ExplosiveSpecialist", false], ["UavHacker", false], ["CamouflageCoef", 1], ["AudibleCoef", 1], ["LoadCoef", 1], ["test", "custom"] ] */
Example 2:
private _unitTraits = getAllUnitTraits _unit; private _indexes = [_unitTraits, "Medic"] call BIS_fnc_findNestedElement; private _unitCanHeal = _unitTraits select (_indexes select 0) select 1;
Example 3:
Since Arma 3 logo black.png2.18:
hint str getAllUnitTraits "O_Engineer_F"; /* [ ["Medic", false], ["Engineer", true], ["ExplosiveSpecialist", true], ["UavHacker", false], ["CamouflageCoef", 1], ["AudibleCoef", 1], ["LoadCoef", 1] ] */

Additional Information

See also:
getUnitTrait setUnitTrait

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
BrettMayson - c
Posted on Nov 27, 2023 - 02:54 (UTC)
Local argument assumed, needs confirmation