Arma 3 Scripting

Command in Vehicle Inventory, Unit Inventory

addWeaponGlobal

Also available as Markdown and JSON, or read the original wiki page.

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:

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

Community notes

Killzone_Kid

If you do not remove weapon first, using this command from dedicated server will duplicate weapon.