selectWeapon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(locality added)
(missing line breaks)
Line 15: Line 15:
Note: For weapons that have more than one muzzle, you have to input the <u>muzzlename</u> and '''not''' the weaponName.
Note: For weapons that have more than one muzzle, you have to input the <u>muzzlename</u> and '''not''' the weaponName.


The only weapons that have muzzleNames seem to be rifles with grenade launchers, handgrenades, smokeshells and satchels.
<br/>The only weapons that have muzzleNames seem to be rifles with grenade launchers, handgrenades, smokeshells and satchels.


In all other cases the weaponName must be used.
<br/>In all other cases the weaponName must be used.
Fortunately, in OFP, in most cases, both names are the same. But check.
Fortunately, in OFP, in most cases, both names are the same. But check.


In ArmA the weaponNames and muzzleNames are different.
<br/>In ArmA the weaponNames and muzzleNames are different.


For muzzle names see [[:Category:Weapons|cfgWeapons]].  
<br/>For muzzle names see [[:Category:Weapons|cfgWeapons]].  


'''NOTE:''' The unit must be [[local]] to the PC on which command is executed. |= Description
<br/>'''NOTE:''' The unit must be [[local]] to the PC on which command is executed. |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 35: Line 35:
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <pre>_soldier1 selectWeapon "LAWLauncher"</pre> |= Example 1
|x1= <code>_soldier1 [[selectWeapon]] "LAWLauncher";</code> |= Example 1
|x2= <pre>player selectWeapon "M203Muzzle"</pre> |= Example 2
|x2= <code>[[player]] [[selectWeapon]] "M203Muzzle";</code> |= Example 2


____________________________________________________________________________________________
____________________________________________________________________________________________


| [[ArmA:_Actions#SWITCHWEAPON|action SwitchWeapon]], [[ArmA:_Actions#SWITCHMAGAZINE|action SwitchMagazine]], [[primaryWeapon]] |= See also
| [[fire]], [[forceWeaponFire]], [[primaryWeapon]], [[handgunWeapon]], [[secondaryWeapon]], [[weapons]], [[ArmA:_Actions#SWITCHWEAPON|action SwitchWeapon]], [[ArmA:_Actions#SWITCHMAGAZINE|action SwitchMagazine]]|= See also


}}
}}
Line 52: Line 52:
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>
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
<pre>
  // Desc: select default weapon & handle multiple muzzles
  // Desc: select default weapon & handle multiple muzzles
  if (count weapons player > 0) then
  if (count weapons player > 0) then
Line 70: Line 71:
   };
   };
  };
  };
 
</pre>


<dd class="notedate">Posted on 22 Mar, 2010
<dd class="notedate">Posted on 22 Mar, 2010
Line 76: Line 77:
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) :  
 
<pre>
  if ( (primaryWeapon player) != "") then
  if ( (primaryWeapon player) != "") then
  {
  {
Line 94: Line 95:
   };
   };
  };
  };
 
</pre>


<!-- Note Section END -->
<!-- Note Section END -->

Revision as of 12:43, 25 February 2014

Hover & click on the images for description

Description

Description:
Selects the given weapon. Note: For weapons that have more than one muzzle, you have to input the muzzlename and not the weaponName.
The only weapons that have muzzleNames seem to be rifles with grenade launchers, handgrenades, smokeshells and satchels.
In all other cases the weaponName must be used. Fortunately, in OFP, in most cases, both names are the same. But check.
In ArmA the weaponNames and muzzleNames are different.
For muzzle names see cfgWeapons.
NOTE: The unit must be local to the PC on which command is executed.
Groups:
Uncategorised

Syntax

Syntax:
unitName selectWeapon muzzleName
Parameters:
unitName: Object
muzzleName: String
Return Value:
Nothing

Examples

Example 1:
_soldier1 selectWeapon "LAWLauncher";
Example 2:
player selectWeapon "M203Muzzle";

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

Notes

Posted on 5 Aug, 2008
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;
   };
 };
Posted on 22 Mar, 2010
MaestrO.fr
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;
   };
 };

Bottom Section