Arma 3 Scripting

Command in Weapons

selectWeapon

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

Description

Selects the given weapon.

Note

Passing empty string will not deselect current weapon. Use 'SwitchWeapon' action instead:

player action ["SwitchWeapon", player, player, -1]

Syntax

Syntax 1

unitName selectWeapon muzzleName

Parameters:

Returns: Nothing

Syntax 2

since arma3 2.08

unit selectWeapon [weapon, muzzle, firemode]

Parameters:

Returns: Boolean or Nothing - true on success, false on failure, Nothing when the call to the command is dispatched over network

Examples

Example 1

_soldier1 selectWeapon "LAWLauncher";

Example 2

player selectWeapon "M203Muzzle";

Example 3

player selectWeapon ["arifle_MX_GL_ACO_F", "arifle_MX_GL_ACO_F", "FullAuto"];

See also

fire · forceWeaponFire · primaryWeapon · handgunWeapon · secondaryWeapon · weapons · ArmA: Actions · isSwitchingWeapon

Community notes

Dr_Eyeball

Rather than simply using selectWeapon to select your default weapon after adding them to your player, it is recommended you use a script instead similar to the following, which caters for multiple muzzles:

SelectWeapon.sqf

// Desc: select default weapon & handle multiple muzzles
if (count weapons player > 0) then
{
    private ['_type', '_muzzles'];

    _type = ((weapons player) select 0);
    // check for multiple muzzles (eg: GL)
    _muzzles = getArray (configFile >> "cfgWeapons" >> _type >> "muzzles");

    if (count _muzzles > 1) then
    {
        player selectWeapon (_muzzles select 0);
    }
    else
    {
        player selectWeapon _type;
    };
};