selectWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
Line 38: Line 38:
* In {{ofp}}, in most cases, both names are the same. But check.
* In {{ofp}}, in most cases, both names are the same. But check.
* In {{arma1}} the weaponNames and muzzleNames are different.
* In {{arma1}} the weaponNames and muzzleNames are different.
* For muzzle names see [[:Category:Weapons|CfgWeapons]].}}
* For muzzle names see [[:Category:Weapons|CfgWeapons]].
}}


|r1= [[Nothing]]
|r1= [[Nothing]]


|s2= unit [[selectWeapon]] [weapon, muzzle, firemode]        Since Arma 3 v2.07.148228
|s2= unit [[selectWeapon]] [weapon, muzzle, firemode]


|p21= unit: [[Object]] - person. This argument has to be [[local]], or it can be remote when executed on the [[isServer | server]]
|s2since= arma3 2.08
 
|p21= unit: [[Object]] - person. This argument has to be [[local]], or it can be remote when executed on the [[isServer|server]]


|p22= weapon: [[String]] - Name of the weapon, personal or vehicle's weapon (see [[weaponState]])
|p22= weapon: [[String]] - Name of the weapon, personal or vehicle's weapon (see [[weaponState]])
|p23= muzzle: [[String]] - Name of the selected muzzle (see [[weaponState]])
|p23= muzzle: [[String]] - Name of the selected muzzle (see [[weaponState]])
|p24= firemode: [[String]] - Name of the firemode (see [[weaponState]])
|p24= firemode: [[String]] - Name of the firemode (see [[weaponState]])


|r2= [[Bool]] or [[Nothing]] - [[true]] on success, [[false]] on failure, [[Nothing]] when the call to the command is dispatched over network
|r2= [[Bool]] or [[Nothing]] - [[true]] on success, [[false]] on failure, [[Nothing]] when the call to the command is dispatched over network


|x1= <code>_soldier1 [[selectWeapon]] "LAWLauncher";</code>
|x1= <code>_soldier1 [[selectWeapon]] "LAWLauncher";</code>
Line 62: Line 66:
}}
}}


<dl class="command_description">
{{Note
 
|user= Dr_Eyeball
<dt><dt>
|timestamp= 20080805094900
<dd class="notedate">Posted on 5 Aug, 2008</dd>
|text= 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:<br>
<dt class="note">[[User:Dr_Eyeball|Dr_Eyeball]]</dt>
<dd class="note">
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:<br>
SelectWeapon.sqf
SelectWeapon.sqf
<code>{{cc|Desc: select default weapon & handle multiple muzzles}}
<code>{{cc|Desc: select default weapon & handle multiple muzzles}}
Line 89: Line 90:
};
};
</code>
</code>
</dd>
}}


<dt><dt>
{{Note
<dd class="notedate">Posted on 22 Mar, 2010</dd>
|user= MaestrO.fr
<dt class="note">[[User:MaestrO.fr|MaestrO.fr]]</dt>
|timestamp= 20100322154500
<dd class="note">
|text= Can be used with [[primaryWeapon]] to select the primary weapon.
Can be used with [[primaryWeapon]] to select the primary weapon.
An example with muzzle care (see Dr_EyeBall note) :  
An example with muzzle care (see Dr_EyeBall note) :  
<code>[[if]] (([[primaryWeapon]] [[player]]) != "") [[then]]
<code>[[if]] (([[primaryWeapon]] [[player]]) != "") [[then]]
Line 115: Line 115:
};
};
</code>
</code>
</dd>
}}
 
</dl>

Revision as of 20:46, 3 October 2021

Hover & click on the images for description

Description

Description:
Selects the given weapon.
Groups:
Weapons

Syntax

Syntax:
unitName selectWeapon muzzleName
Parameters:
unitName: Object
muzzleName: String - Name of the weapon or muzzle
For weapons that have more than one muzzle, you have to input the muzzleName and not the weaponName.
  • In Operation Flashpoint, in most cases, both names are the same. But check.
  • In Armed Assault the weaponNames and muzzleNames are different.
  • For muzzle names see CfgWeapons.
Return Value:
Nothing

Alternative Syntax

Syntax:
unit selectWeapon [weapon, muzzle, firemode]
Parameters:
unit: Object - person. This argument has to be local, or it can be remote when executed on the server
weapon: String - Name of the weapon, personal or vehicle's weapon (see weaponState)
muzzle: String - Name of the selected muzzle (see weaponState)
firemode: String - Name of the firemode (see weaponState)
Return Value:
Bool 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"];

Additional Information

See also:
fireforceWeaponFireprimaryWeaponhandgunWeaponsecondaryWeaponweaponsaction SwitchWeaponaction SwitchMagazine

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Dr_Eyeball - c
Posted on Aug 05, 2008 - 09:49 (UTC)
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; }; };
MaestrO.fr - c
Posted on Mar 22, 2010 - 15:45 (UTC)
Can be used with primaryWeapon to select the primary weapon. An example with muzzle care (see Dr_EyeBall note) : if ((primaryWeapon player) != "") then { private ['_type', '_muzzles']; _type = primaryWeapon player; // 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; }; };