getAllUnitTraits: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
(Add 2.16 syntax)
Line 17: Line 17:
* name: [[String]] - trait's name
* name: [[String]] - trait's name
* value [[String]] or [[Boolean]] - trait's value
* value [[String]] or [[Boolean]] - trait's value
|s2= [[getAllUnitTraits]] configClass
|s2since= arma3 2.16
|p21= configClass: [[String]]
|r2= same as {{Link|#Syntax 1}}


|x1= <sqf>
|x1= <sqf>
Line 38: Line 46:
private _indexes = [_unitTraits, "Medic"] call BIS_fnc_findNestedElement;
private _indexes = [_unitTraits, "Medic"] call BIS_fnc_findNestedElement;
private _unitCanHeal = _unitTraits select (_indexes select 0) select 1;
private _unitCanHeal = _unitTraits select (_indexes select 0) select 1;
</sqf>
|x3= Since {{GVI|arma3|2.16|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>
</sqf>


|seealso= [[setUnitTrait]]
|seealso= [[setUnitTrait]]
}}
}}

Revision as of 18:39, 24 October 2023

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 in format [name, value] where:

Alternative Syntax

Syntax:
getAllUnitTraits configClass
Parameters:
configClass: String
Return Value:
same as Syntax 1

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;
Example 3:
Since Arma 3 logo black.png2.16
/* [ ["Medic", false], ["Engineer", true], ["ExplosiveSpecialist", true], ["UavHacker", false], ["CamouflageCoef", 1], ["AudibleCoef", 1], ["LoadCoef", 1] ] */ hint str getAllUnitTraits "O_Engineer_F";

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