canAddItemToBackpack: Difference between revisions
Jump to navigation
Jump to search
Hypoxic125 (talk | contribs) (Added potential warning message: bad vehicle type if empty string is passed) |
Lou Montana (talk | contribs) m (Text replacement - "none|400px|alt=Warning Message: Bad vehicle type|Warning Message: Bad vehicle type" to "none|alt= Warning Message: Bad vehicle type|Warning Message: Bad vehicle type") |
||
Line 10: | Line 10: | ||
{{Feature|important| | {{Feature|important| | ||
Avoid passing an empty string <sqf inline>""</sqf> to this command as it will create a warning dialog: | Avoid passing an empty string <sqf inline>""</sqf> to this command as it will create a warning dialog: | ||
[[File:a3 warning badvehicletype.jpg|none | [[File:a3 warning badvehicletype.jpg|none|alt= Warning Message: Bad vehicle type|Warning Message: Bad vehicle type]] | ||
This message will show once per mission restart. | This message will show once per mission restart. | ||
}} | }} |
Latest revision as of 11:33, 3 September 2024
Description
- Description:
- Checks if given object can be stored into soldier's backpack.
- Groups:
- Containers
Syntax
- Syntax:
- unit canAddItemToBackpack item
- Parameters:
- unit: Object
- item: String
- Return Value:
- Boolean
Alternative Syntax
- Syntax:
- unit canAddItemToBackpack [item, count, ignoreSoldierMaxLoad]
- Parameters:
- unit: Object
- item: String
- count: Number
- since 2.18
- ignoreSoldierMaxLoad: Boolean - (Optional, default false) true to ignore 'soldierMaxLoad' param, container maxLoad is still counted.
- Return Value:
- Boolean
Examples
- Example 1:
Additional Information
- See also:
- canAdd canAddItemToUniform canAddItemToVest backpackContainer firstBackpack unitBackpack backpack backpackCargo getBackpackCargo backpackItems addBackpack addBackpackCargo addBackpackCargoGlobal removeBackpack clearBackpackCargo clearBackpackCargoGlobal clearAllItemsFromBackpack loadBackpack backpackSpaceFor addItemToBackpack removeItemFromBackpack everyBackpack
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
- Posted on Mar 29, 2022 - 04:56 (UTC)
-
This command is very unreliable, along with all other canAdd commands. For example, in the inventory screen, an empty "B_Bergen_dgtl_F" backpack can fit a total of 30 "5Rnd_127x108_APDS_Mag" mags. However, player canAddItemToBackpack "5Rnd_127x108_APDS_Mag" starts returning false once there are 17 in the backpack. Furthermore, if the player has equipped an empty PCML launcher (without any missile in his inventory), the command starts returning false once there are only 11, despite the fact that the launcher has no effect on backpack space...
I wrote a function almost 9 years ago to bypass this (surprisingly still existing) bug. You can check it here, with a usage example here.