{"name":"addWeaponGlobal","operator":null,"title":"addWeaponGlobal","type":"command","url":"https://community.bistudio.com/wiki/addWeaponGlobal","revid":373148,"updated":"2025-04-04T06:15:52Z","groups":["Vehicle Inventory","Unit Inventory"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"0.76"}],"since":{"game":"arma3","name":"Arma 3","version":"0.76"},"arma3_since":"0.76","branch":null,"locality":{"argument":"global","effect":"global","server_exec":false},"exec":null,"description":"Add a weapon to a unit. Infantry units can only carry weapons in their respective slots (primary, secondary and handgun),\nthe addWeaponGlobal command will replace the weapon currently in a slot with the added weapon if it shares the same slot.\nThis command can link items to respective slots as well, in which case the functionality is identical to linkItem.\n\nTo make sure the added weapon is loaded and ready, add the magazine first.\n\n> [!NOTE]\n> This command was broken when used on dedicated server and fixed on Arma 3 v2.00.","syntaxes":[{"syntax":"object addWeaponGlobal weapon","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":"unit or vehicle to add the weapon to","types":["Object"],"since":null,"text":"object : Object - unit or vehicle to add the weapon to"},{"name":"weapon","type":"String","optional":false,"default":null,"description":"weapon class name","types":["String"],"since":null,"text":"weapon: String - weapon class name"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"weapon","types":["String"]}},{"syntax":"object addWeaponGlobal [weapon, autoselect]","since":"arma3 2.20","effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":"unit or vehicle to add the weapon to","types":["Object"],"since":null,"text":"object: Object - unit or vehicle to add the weapon to"},{"name":"weapon","type":"String","optional":false,"default":null,"description":"weapon class name. See the topic Category:Weapons for reference about possible values.","types":["String"],"since":null,"text":"weapon: String - weapon class name. See the topic Category:Weapons for reference about possible values."},{"name":"autoselect","type":"String","optional":true,"default":"true","description":"false to abort weapon autoselection if no weapon was selected.","types":["String"],"since":null,"text":"autoselect: String - (Optional, default true) false to abort weapon autoselection if no weapon was selected."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"object","types":["Object"]},"right":{"text":"[weapon, autoselect]","types":["Array"]}}],"examples":[{"text":"```sqf\n{\n    _x addMagazineGlobal \"Laserbatteries\";\n    _x addWeaponGlobal \"Laserdesignator\";\n} forEach allUnits;\n```","code":["{\n\t_x addMagazineGlobal \"Laserbatteries\";\n\t_x addWeaponGlobal \"Laserdesignator\";\n} forEach allUnits;"]},{"text":"```sqf\n{\n    if (typeOf _x == \"O_Heli_Attack_02_black_F\") then\n    {\n        _x addMagazineGlobal \"38Rnd_80mm_rockets\";\n        _x addWeaponGlobal \"rockets_Skyfire\";\n    };\n} forEach vehicles;\n```","code":["{\n\tif (typeOf _x == \"O_Heli_Attack_02_black_F\") then\n\t{\n\t\t_x addMagazineGlobal \"38Rnd_80mm_rockets\";\n\t\t_x addWeaponGlobal \"rockets_Skyfire\";\n\t};\n} forEach vehicles;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["removeWeaponGlobal","addWeapon","addMagazine","addMagazineGlobal"],"notes":[{"user":"Killzone_Kid","date":"2015-07-07T18:42:00Z","text":"If you do not remove weapon first, using this command from dedicated server will duplicate weapon."}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Unit Inventory","Command Group: Vehicle Inventory","Introduced with Arma 3 version 0.76","Scripting Commands","Scripting Commands: Global Effect"]}