{"name":"canAdd","title":"canAdd","type":"command","url":"https://community.bistudio.com/wiki/canAdd","revid":379207,"updated":"2026-10-30T21:13:13Z","groups":["Unit Inventory"],"status":"ok","games":{"arma3":"0.70"},"since":"arma3 0.70","arma3_since":"0.70","description":"Checks if given object can be stored in inventory of given object or any inventory container (uniform, vest, backpack) of given unit.\nBefore Arma 3 v2.10 this comment verified only the biggest container when multiple items were queried; now it checks all containers.\n\n> [!IMPORTANT]\n> Avoid passing an empty string `\"\"` to this command as it will create a warning dialog:\n>\n> Warning Message: Bad vehicle type\n>\n> This message will show once per mission restart.","syntaxes":[{"syntax":"object canAdd item","params":[{"name":"object","type":"Object","description":"unit or container","type_expr":"Object"},{"name":"item","type":"String","description":"config class","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"object"},"right":{"text":"item"}},{"syntax":"object canAdd [item, count, ignoreSoldierMaxLoad]","since":"arma3 1.56","params":[{"name":"object","type":"Object","description":"unit or container","type_expr":"Object"},{"name":"item","type":"String","description":"config class","type_expr":"String"},{"name":"count","type":"Number","description":"desired quantity","type_expr":"Number"},{"name":"ignoreSoldierMaxLoad","type":"Boolean","optional":true,"default":"false","description":"true to ignore 'soldierMaxLoad' param, container's maxLoad is still counted","type_expr":"Boolean","since":"arma3 2.18","text":"ignoreSoldierMaxLoad: Boolean - (Optional, default false) true to ignore 'soldierMaxLoad' param, container's maxLoad is still counted"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"object"},"right":{"text":"[item, count, ignoreSoldierMaxLoad]"}},{"syntax":"weapon canAdd item","since":"arma3 2.10","params":[{"name":"weapon","type":"String","description":"weapon class name","type_expr":"String"},{"name":"item","type":"String","description":"config class of magazine or attachment","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"weapon"},"right":{"text":"item"}},{"syntax":"weapon canAdd [attachment, slot]","since":"arma3 2.10","params":[{"name":"weapon","type":"String","description":"weapon class name","type_expr":"String"},{"name":"attachment","type":"String","description":"attachment class name","type_expr":"String"},{"name":"slot","type":"String","description":"slot class name (defined under **WeaponSlotsInfo** class in weapon config), for example:\n\n- \"CowsSlot\" for optics\n- \"MuzzleSlot\" for silencers\n- \"PointerSlot\" for laser pointers and flashlights\n- \"UnderBarrelSlot\" for bipods","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"weapon"},"right":{"text":"[attachment, slot]"}},{"syntax":"weapon canAdd [magazine, muzzle]","since":"arma3 2.10","params":[{"name":"weapon","type":"String","description":"weapon class name","type_expr":"String"},{"name":"magazine","type":"String","description":"magazine class name","type_expr":"String"},{"name":"muzzle","type":"String","description":"muzzle class name","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"weapon"},"right":{"text":"[magazine, muzzle]"}}],"examples":[{"text":"```sqf\nif (player canAdd \"FirstAidKit\") then\n{\n    player addItem \"FirstAidKit\";\n}\nelse\n{\n    hint \"Not enough space\";\n};\n```","code":["if (player canAdd \"FirstAidKit\") then\n{\n\tplayer addItem \"FirstAidKit\";\n}\nelse\n{\n\thint \"Not enough space\";\n};"]},{"text":"```sqf\nif (_box canAdd \"FirstAidKit\") then\n{\n    _box addWeaponCargo [\"FirstAidKit\", 1];\n}\nelse\n{\n    hint \"Not enough space\";\n};\n```","code":["if (_box canAdd \"FirstAidKit\") then\n{\n\t_box addWeaponCargo [\"FirstAidKit\", 1];\n}\nelse\n{\n\thint \"Not enough space\";\n};"]},{"code":["car canAdd [currentWeapon player, 50];"]},{"code":["// check if attachment can be loaded\n\"arifle_Katiba_GL_F\" canAdd \"acc_pointer_IR\";\n\"arifle_Katiba_GL_F\" canAdd [\"acc_pointer_IR\", \"PointerSlot\"];"]},{"code":["// check if magazine can be loaded\n\"arifle_Katiba_GL_F\" canAdd \"30Rnd_65x39_caseless_green\";\n\"arifle_Katiba_GL_F\" canAdd [\"30Rnd_65x39_caseless_green\", \"this\"];\n\"arifle_Katiba_GL_F\" canAdd [\"1Rnd_SmokeRed_Grenade_shell\", \"EGLM\"];"]}],"see_also":["canAddItemToBackpack","canAddItemToUniform","canAddItemToVest","compatibleMagazines","compatibleItems","compatibleWeapons"],"notes":[{"user":"Jonpas","date":"2015-11-29T00:02:00Z","text":"Can also be used on any object that has inventory, not only player inventory containers.\n\nWhere **_box** is **B_supplyCrate_F**:\n\n```sqf\n// empty\n_box canAdd \"FirstAidKit\"; // returns true\n\n// full\n_box canAdd \"FirstAidKit\"; // returns false\n```"},{"user":"Demellion","date":"2017-02-11T18:40:00Z","text":"This can also be used as alternative to canAddItemToBackpack, canAddItemToUniform, canAddItemToVest where container might not be strictly defined. In some cases it might be a good optimisation for your code, where you also don't need to perform checks on which type of player container this is. Example:\n\n```sqf\nprivate _container = selectRandom [uniformContainer player, vestContainer player, backpackContainer player];\nif (_container canAdd \"Rangefinder\") then\n{\n    _container addItemCargoGlobal [\"Rangefinder\", 1];\n};\n```"}]}