canAddItemToBackpack: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Note about how this command is blatantly broken) |
||
Line 40: | Line 40: | ||
|text= This command is very unreliable, along with all other <tt>canAdd</tt> commands. For example, in the inventory screen, an empty <tt>"B_Bergen_dgtl_F"</tt> backpack can fit a total of 30 <tt>"5Rnd_127x108_APDS_Mag"</tt> mags. However, <tt>[[player]] [[canAddItemToBackpack]] "5Rnd_127x108_APDS_Mag"</tt> starts returning <tt>false</tt> 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 <tt>false</tt> once there are only 11, despite the fact that the launcher has no effect on backpack space... | |text= This command is very unreliable, along with all other <tt>canAdd</tt> commands. For example, in the inventory screen, an empty <tt>"B_Bergen_dgtl_F"</tt> backpack can fit a total of 30 <tt>"5Rnd_127x108_APDS_Mag"</tt> mags. However, <tt>[[player]] [[canAddItemToBackpack]] "5Rnd_127x108_APDS_Mag"</tt> starts returning <tt>false</tt> 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 <tt>false</tt> once there are only 11, despite the fact that the launcher has no effect on backpack space... | ||
<br> | <br> | ||
I wrote a function | I wrote a function almost 9 years ago to bypass this (surprisingly still existing) bug. You can check it [https://github.com/A3Wasteland/ArmA3_Wasteland.Altis/blob/dev/client/functions/fn_fitsInventory.sqf here], with a usage example [https://github.com/A3Wasteland/ArmA3_Wasteland.Altis/blob/dc41623f154d6c5be683374784aba201a0628e60/client/functions/addWeaponInventory.sqf#L18-L20 here]. | ||
}} | }} |
Revision as of 06:01, 29 March 2022
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]
- Parameters:
- unit: Object
- [item, count]: Array
- item: String
- count: Number
- Return Value:
- Boolean
Examples
- Example 1:
if (player canAddItemToBackpack "HandGrenade") then { player addItemToBackpack _item } else { hint "no room!" };
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.