canAdd: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| Checks if given object can be stored in any inventory container ([[uniform]], [[vest]], [[backpack]]) of given unit. |= Description | | Checks if given object can be stored in inventory of given object or any inventory container ([[uniform]], [[vest]], [[backpack]]) of given unit. |= Description | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | object '''canAdd''' item |= Syntax | ||
|p1= unit: [[Object]] |= PARAMETER1 | |p1= unit or container: [[Object]] |= PARAMETER1 | ||
|p2= item: [[String]] - Config class |= PARAMETER2 | |p2= item: [[String]] - Config class |= PARAMETER2 | ||
Line 26: | Line 26: | ||
}; | }; | ||
</code>|= EXAMPLE1 | </code>|= EXAMPLE1 | ||
|x2= <code>[[if]] (_box [[canAdd]] "FirstAidKit") [[then]] { | |||
_box [[addWeaponCargo]] ["FirstAidKit", 1]; | |||
} [[else]] { | |||
[[hint]] "Not enough space"; | |||
}; | |||
</code>|= EXAMPLE2 | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ |
Revision as of 01:29, 29 November 2015
Description
- Description:
- Checks if given object can be stored in inventory of given object or any inventory container (uniform, vest, backpack) of given unit.
- Groups:
- Uncategorised
Syntax
- Syntax:
- object canAdd item
- Parameters:
- unit or container: Object
- item: String - Config class
- Return Value:
- Boolean
Examples
- Example 1:
if (player canAdd "FirstAidKit") then { player addItem "FirstAidKit"; } else { hint "Not enough space"; };
- Example 2:
if (_box canAdd "FirstAidKit") then { _box addWeaponCargo ["FirstAidKit", 1]; } else { hint "Not enough space"; };
Additional Information
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
Notes
Bottom Section
- Posted on November 29, 2015 - 00:02 (UTC)
- Jonpas
-
Can also be used on any object that has inventory, not only player inventory containers.
Where _box is B_supplyCrate_F:// Empty _box canAdd "FirstAidKit"; -> true // Full _box canAdd "FirstAidKit"; -> false