uniqueUnitItems: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix fix)
(Fix return value)
Line 12: Line 12:
|descr= Returns hashmap of all items in units inventory as [classname, count] pairs.
|descr= Returns hashmap of all items in units inventory as [classname, count] pairs.
{{Feature|informative|
{{Feature|informative|
''weaponItems'', ''uniform'', ''vest'', ''backpack'' arguments use the following [[Number]] values:
* ''weaponItems'', ''uniform'', ''vest'', ''backpack'' arguments use the following [[Number]] values:
* 0: do not return value
** 0: do not return value
* 1: returns container's name (weapon or container)
** 1: returns container only (weapon or container)
* 2: returns container and contents
** 2: returns container and its content
* weapons/containers that are stored inside containers (e.g weapon in backpack) always return all contents if contents for the parent container are enabled.
}}
}}


|gr1= Unit Inventory
|gr1= Unit Inventory


|s1= [[uniqueUnitItems]] [unit, weaponItems, uniform, vest, backpack, assignedItems]
|s1= [[uniqueUnitItems]] [unit, weaponsItems, uniformItems, vestItems, backpackItems, assignedItems]


|p1= unit: [[Object]]
|p1= unit: [[Object]]


|p2= weaponItems: [[Number]]
|p2= weaponsItems: [[Number]] - (Optional, default 2) weapons (including binoculars) and their accessories (flashlight etc), loaded magazines


|p3= uniform: [[Number]]
|p3= uniformItems: [[Number]] - (Optional, default 2)


|p4= vest: [[Number]]
|p4= vestItems: [[Number]] - (Optional, default 2)


|p5= backpack: [[Number]]
|p5= backpackItems: [[Number]] - (Optional, default 2)


|p6= assignedItems: [[Boolean]]
|p6= assignedItems: [[Boolean]] - (Optional, default [[true]]) returns [[assignedItems]] as well as [[headgear]] and [[hmd|goggles]]


|r1= [[HashMap]] <!-- ''TBD'' --><!-- [[Array]] of [[HashMap]]s in format key: containerName ([[String]]) &rarr; value: amount ([[Number]]) -->
|r1= [[HashMap]] in format itemClassname ([[String]]) &rarr; amount ([[Number]])


|x1= <code>[[private]] _unitUniqueItems = [[uniqueUnitItems]] [<nowiki/>[[player]], 0, 2, 2, 2, [[true]]];
|x1= <code>[[private]] _unitUniqueItems = [[uniqueUnitItems]] [<nowiki/>[[player]], 0, 2, 2, 2, [[true]]];
[[if]] (_unitUniqueItems [[getOrDefault]] ["FirstAidKit", 0] > 5) [[then]] { [[hint]] "I'm rich of FAK to give!"; };</code>
[[if]] (_unitUniqueItems [[getOrDefault]] ["FirstAidKit", 0] > 5) [[then]] { [[hint]] "I'm rich of FAK to give!"; };</code>
|x2= <code>[[private]] _unitUniqueItems = [[uniqueUnitItems]] [<nowiki/>[[cursorObject]]];</code>


|seealso= [[getUnitLoadout]]
|seealso= [[getUnitLoadout]]
}}
}}

Revision as of 19:16, 21 July 2021

Hover & click on the images for description
Only available in Development branch(es) until its release with Arma 3 patch v2.06.

Description

Description:
Returns hashmap of all items in units inventory as [classname, count] pairs.
  • weaponItems, uniform, vest, backpack arguments use the following Number values:
    • 0: do not return value
    • 1: returns container only (weapon or container)
    • 2: returns container and its content
  • weapons/containers that are stored inside containers (e.g weapon in backpack) always return all contents if contents for the parent container are enabled.
Groups:
Unit Inventory

Syntax

Syntax:
uniqueUnitItems [unit, weaponsItems, uniformItems, vestItems, backpackItems, assignedItems]
Parameters:
unit: Object
weaponsItems: Number - (Optional, default 2) weapons (including binoculars) and their accessories (flashlight etc), loaded magazines
uniformItems: Number - (Optional, default 2)
vestItems: Number - (Optional, default 2)
backpackItems: Number - (Optional, default 2)
assignedItems: Boolean - (Optional, default true) returns assignedItems as well as headgear and goggles
Return Value:
HashMap in format itemClassname (String) → amount (Number)

Examples

Example 1:
private _unitUniqueItems = uniqueUnitItems [player, 0, 2, 2, 2, true]; if (_unitUniqueItems getOrDefault ["FirstAidKit", 0] > 5) then { hint "I'm rich of FAK to give!"; };
Example 2:
private _unitUniqueItems = uniqueUnitItems [cursorObject];

Additional Information

See also:
getUnitLoadout

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