{"name":"addBackpackGlobal","title":"addBackpackGlobal","type":"command","url":"https://community.bistudio.com/wiki/addBackpackGlobal","revid":369079,"updated":"2024-09-02T20:35:57Z","groups":["Unit Inventory"],"status":"ok","games":{"arma3":"1.32"},"since":"arma3 1.32","arma3_since":"1.32","locality":{"argument":"global","effect":"global"},"description":"Adds a backpack to a unit - global variant of addBackpack.\n\n> [!WARNING]\n> The backpack added with this command will be created on the PC local to the unit you are adding it to, even if executed on the server.\n>\n> Because of this, if non-local unit is the target and one tries to immediately access added backpack, the backpack returned will be null.\n>\n> When adding backpack dynamically to a remote unit, wait until the backpack is added (See Example 2).","syntaxes":[{"syntax":"unit addBackpackGlobal backpack","params":[{"name":"unit","type":"Object","description":"soldier","type_expr":"Object"},{"name":"backpack","type":"String","description":"backpack class name","type_expr":"String"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"unit"},"right":{"text":"backpack"}}],"examples":[{"code":["player addBackpackGlobal \"B_AssaultPack_khk\";"]},{"text":"```sqf\n_unit spawn\n{\n    if (not isNull backpackContainer _this) then\n    {\n        removeBackpackGlobal _this;\n        waitUntil { sleep 0.01; isNull backpackContainer _this };\n    };\n\n    _this addBackpackGlobal \"B_AssaultPack_khk\";\n    waitUntil { sleep 0.01; not isNull backpackContainer _this };\n    backpackContainer _this addMagazineCargoGlobal [\"30Rnd_556x45_Stanag\", 5];\n};\n```","code":["_unit spawn \n{\n\tif (not isNull backpackContainer _this) then\n\t{\n\t\tremoveBackpackGlobal _this;\n\t\twaitUntil { sleep 0.01; isNull backpackContainer _this };\n\t};\n\n\t_this addBackpackGlobal \"B_AssaultPack_khk\";\n\twaitUntil { sleep 0.01; not isNull backpackContainer _this };\n\tbackpackContainer _this addMagazineCargoGlobal [\"30Rnd_556x45_Stanag\", 5];\n};"]}],"see_also":["addBackpack","backpackContainer","firstBackpack","unitBackpack","backpack","backpackCargo","getBackpackCargo","backpackItems","addBackpackCargo","addBackpackCargoGlobal","removeBackpack","clearBackpackCargo","clearBackpackCargoGlobal","clearAllItemsFromBackpack","loadBackpack","backpackSpaceFor","canAddItemToBackpack","addItemToBackpack","removeItemFromBackpack","everyBackpack"]}