getAllUnitTraits: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " *\|Problems= * " to " ")
m (2.16 -> 2.18)
 
(11 intermediate revisions by 3 users not shown)
Line 2: Line 2:


|game1= arma3
|game1= arma3
|version1= 2.00
|version1= 2.00


|arg= <!-- local, to be confirmed -->
|arg= local
 
|eff=
 
|serverExec=


|gr1= Object Manipulation
|gr1= Object Manipulation


|descr= Returns unit traits, native or set by [[setUnitTrait]].
|descr= Returns unit traits (native or set by [[setUnitTrait]]).
 
|mp= |Multiplayer Behaviour=
 
|pr=


|s1= [[getAllUnitTraits]] unit
|s1= [[getAllUnitTraits]] unit


|p1= unit: [[Object]]
|p1= unit: [[Object]] or {{GVI|arma3|2.18|size= 0.75}} [[String]] - a unit or a class name


|r1= [[Array]] of [[Array]]s of [<nowiki/>[[String]], [[String]]/[[Boolean]]] - to format [["traitName1",value1], ["traitName2", value2]]
|r1= [[Array]] of [[Array]]s in format [name, value] where:
* name: [[String]] - trait's name
* value [[String]] or [[Boolean]] - trait's value


|x1= <code>{{codecomment|/* can return:
|x1= <sqf>
/*
Could return something like this:
[
[
["Medic", false],
["Medic", false],
Line 36: Line 31:
["test", "custom"]
["test", "custom"]
]
]
<nowiki/>*/}}
*/
[[private]] _playerTraits = [[getAllUnitTraits]] [[player]];</code>
private _playerTraits = getAllUnitTraits player;
</sqf>


|x2= <code>[[private]] _unitTraits = [[getAllUnitTraits]] _unit;
|x2= <sqf>
[[private]] _indexes = [_unitTraits, "Medic"] [[call]] [[BIS_fnc_findNestedElement]];
private _unitTraits = getAllUnitTraits _unit;
[[private]] _unitCanHeal = _unitTraits [[select]] (_indexes [[select]] 0) [[select]] 1;</code>
private _indexes = [_unitTraits, "Medic"] call BIS_fnc_findNestedElement;
private _unitCanHeal = _unitTraits select (_indexes select 0) select 1;
</sqf>


|seealso= [[setUnitTrait]]
|x3= Since {{GVI|arma3|2.18|size= 0.75}}:
<sqf>
/*
[
["Medic", false],
["Engineer", true],
["ExplosiveSpecialist", true],
["UavHacker", false],
["CamouflageCoef", 1],
["AudibleCoef", 1],
["LoadCoef", 1]
]
*/
hint str getAllUnitTraits "O_Engineer_F";
</sqf>
 
|seealso= [[getUnitTrait]] [[setUnitTrait]]
}}
}}


<dl class="command_description">
{{Note
<!-- BEGIN Note Section -->
|user= Unknown
<!-- For example:
|text= Local argument assumed, may need confirmation
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
}}
<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>

Latest revision as of 16:11, 8 February 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:
/* Could return something like this: [ ["Medic", false], ["Engineer", false], ["ExplosiveSpecialist", false], ["UavHacker", false], ["CamouflageCoef", 1], ["AudibleCoef", 1], ["LoadCoef", 1], ["test", "custom"] ] */ private _playerTraits = getAllUnitTraits player;
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:
/* [ ["Medic", false], ["Engineer", true], ["ExplosiveSpecialist", true], ["UavHacker", false], ["CamouflageCoef", 1], ["AudibleCoef", 1], ["LoadCoef", 1] ] */ hint str getAllUnitTraits "O_Engineer_F";

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
Unknown - c
Date unknown
Local argument assumed, may need confirmation