{"name":"BIS_fnc_addWeapon","operator":null,"title":"BIS fnc addWeapon","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_addWeapon","revid":349361,"updated":"2023-11-08T15:35:10Z","groups":["Inventory","Weapons"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.00"}],"since":{"game":"arma3","name":"Arma 3","version":"1.00"},"arma3_since":"1.00","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Adds a weapon to the specified unit, with magazine classnames taken from the weapon's config (in CfgWeapons).\nThis function does not remove magazines nor weapons prior to adding the new weapon, so that still has to be done manually.","syntaxes":[{"syntax":"[unit, weaponClassName, quantity, type] call BIS_fnc_addWeapon","since":null,"effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":"unit to add weapon to.","types":["Object"],"since":null,"text":"unit: Object - unit to add weapon to."},{"name":"weaponClassName","type":"String","optional":false,"default":null,"description":"weapon Classname (found in CfgWeapons).","types":["String"],"since":null,"text":"weaponClassName: String - weapon Classname (found in CfgWeapons)."},{"name":"quantity","type":"Number","optional":false,"default":null,"description":"amount of magazines.","types":["Number"],"since":null,"text":"quantity: Number - amount of magazines."},{"name":"type","type":"Number or String","optional":true,"default":"0","description":"Number - Index of magazine name that should be used - found in `magazines = {}` array.\n- String - Magazine name to be used.","types":["Number","String"],"since":null,"text":"type: Number or String - (Optional, default 0)\n- Number - Index of magazine name that should be used - found in `magazines = {}` array.\n- String - Magazine name to be used."}],"returns":{"type":"String","types":["String"],"description":"primary(!) muzzle name of weapon.","text":"String - primary**(!)** muzzle name of weapon."}}],"examples":[{"text":"Add 6 dual-purpose magazines and the underwater gun to the player:\n\n```sqf\n[player, \"arifle_SDAR_F\", 6] call BIS_fnc_addWeapon;\n```","code":["[player, \"arifle_SDAR_F\", 6] call BIS_fnc_addWeapon;"]},{"text":"Adds 2 × 30 Rnd Stanag Tracer (Red) magazines to bluforUnit, with an Mk20_F:\n\n```sqf\n[bluforUnit, \"arifle_Mk20_F\", 2, 1] call BIS_fnc_addWeapon;\n```","code":["[bluforUnit, \"arifle_Mk20_F\", 2, 1] call BIS_fnc_addWeapon;"]},{"text":"Alternative syntax of second example, with magazine name written out:\n\n```sqf\n[bluforUnit, \"arifle_Mk20_F\", 2, \"30Rnd_556x45_Stanag_Tracer_red\"] call BIS_fnc_addWeapon;\n```","code":["[bluforUnit, \"arifle_Mk20_F\", 2, \"30Rnd_556x45_Stanag_Tracer_red\"] call BIS_fnc_addWeapon;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["addWeapon","selectWeapon"],"notes":[{"user":"Tryteyker-","date":"2014-09-29T18:13:00Z","text":"This function only returns the primary muzzle name of a gun. For more info on how to select guns' secondary muzzle names (like an underhand grenade launcher), view the notes on selectWeapon."}],"categories":["Arma 3: Functions","Arma 3: New Functions","Function Group: Inventory","Function Group: Weapons","Functions","Introduced with Arma 3 version 1.00"],"docblock":null,"filled_from_docblock":[]}