If you do not remove weapon first, using this command from dedicated server will duplicate weapon.
Description
Add a weapon to a unit. Infantry units can only carry weapons in their respective slots (primary, secondary and handgun), the addWeaponGlobal command will replace the weapon currently in a slot with the added weapon if it shares the same slot. This command can link items to respective slots as well, in which case the functionality is identical to linkItem.
To make sure the added weapon is loaded and ready, add the magazine first.
Note
This command was broken when used on dedicated server and fixed on Arma 3 v2.00.
Syntax
Syntax 1
object addWeaponGlobal weapon
Parameters:
Returns: Nothing
Syntax 2
since arma3 2.20
object addWeaponGlobal [weapon, autoselect]
Parameters:
object: Object - unit or vehicle to add the weapon toweapon: String - weapon class name. See the topic Category:Weapons for reference about possible values.autoselect: String - (Optional, default true) false to abort weapon autoselection if no weapon was selected.
Returns: Nothing
Examples
Example 1
{
_x addMagazineGlobal "Laserbatteries";
_x addWeaponGlobal "Laserdesignator";
} forEach allUnits;
Example 2
{
if (typeOf _x == "O_Heli_Attack_02_black_F") then
{
_x addMagazineGlobal "38Rnd_80mm_rockets";
_x addWeaponGlobal "rockets_Skyfire";
};
} forEach vehicles;
See also
removeWeaponGlobal · addWeapon · addMagazine · addMagazineGlobal