getAllUnitTraits: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "_this" to "_this")
m (Text replacement - " <dl class="command_description"> <!-- BEGIN Note Section --> <!-- For example: <dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd> <dt class="note">User Name</dt> <dd class="note">This is an example...)
Line 45: Line 45:
|seealso= [[setUnitTrait]]
|seealso= [[setUnitTrait]]
}}
}}
<dl class="command_description">
<!-- BEGIN Note Section -->
<!-- For example:
<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]] ([[Magic Variables#this|_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
-->
<!-- END Note Section -->
</dl>

Revision as of 19:03, 1 March 2021

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
Return Value:
Array of Arrays of [String, String/Boolean] - to format [["traitName1",value1], ["traitName2", value2]]

Examples

Example 1:
/* can return: [ ["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;

Additional Information

See also:
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