{"name":"addWeapon","title":"addWeapon","type":"command","url":"https://community.bistudio.com/wiki/addWeapon","revid":373145,"updated":"2025-04-04T06:14:28Z","groups":["Unit Inventory","Vehicle Inventory"],"status":"ok","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","locality":{"argument":"local","effect":"global"},"description":"Add a weapon to a unit. For a global version of this command see addWeaponGlobal.\n\nInfantry units can only carry a specific number of weapons, once the weapon slots are filled, any further addWeapon commands are ignored.\n\n> [!NOTE]\n> a **magazine** must be added first for the added weapon to be loaded.\n\n> [!WARNING]\n> In Arma 3 this command can also link items to the inventory slots, the functionality is identical to linkItem command, which it global and thus differ in how it should be used.","syntaxes":[{"syntax":"object addWeapon weapon","params":[{"name":"object","type":"Object","description":"unit or vehicle to add the weapon to","type_expr":"Object"},{"name":"weapon","type":"String","description":"weapon class name. See the topic Category:Weapons for reference about possible values.","type_expr":"String"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"object"},"right":{"text":"weapon"}},{"syntax":"object addWeapon [weapon, autoselect]","since":"arma3 2.20","params":[{"name":"object","type":"Object","description":"unit or vehicle to add the weapon to","type_expr":"Object"},{"name":"weapon","type":"String","description":"weapon class name. See the topic Category:Weapons for reference about possible values.","type_expr":"String"},{"name":"autoselect","type":"String","optional":true,"default":"true","description":"false to abort weapon autoselection if no weapon was selected.","type_expr":"String","text":"autoselect: String - (Optional, default true) false to abort weapon autoselection if no weapon was selected."}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"object"},"right":{"text":"[weapon, autoselect]"}}],"examples":[{"code":["player addMagazine \"30Rnd_556x45_Stanag\";\nplayer addWeapon \"BAF_L85A2_RIS_SUSAT\";"]},{"code":["An_2 addMagazine \"100Rnd_762x51_M240\";\nAn_2 addWeapon \"M240_veh\";"]}],"see_also":["addWeaponGlobal","addWeaponTurret","removeWeapon","removeAllWeapons","addMagazine"]}