weaponState: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(optional param, command improvement)
(examples)
Line 28: Line 28:
|s2= '''weaponState''' [vehicle, turretPath, weapon] |= Syntax
|s2= '''weaponState''' [vehicle, turretPath, weapon] |= Syntax


|p21 =  [vehicle, turretPath]: [[Array]] |=
|p21 =  [vehicle, turretPath, weapon]: [[Array]] |=
|p22= vehicle: [[Object]] |= Parameter 1
|p22= vehicle: [[Object]] |= Parameter 1
|p23= turretPath: [[Array]] |= Parameter 2
|p23= turretPath: [[Array]] |= Parameter 2
Line 41: Line 41:
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>_wsPlayer <nowiki>=</nowiki> [[weaponState]] [[player]];// ["m16a4","m16a4","Single","30Rnd_556x45_Stanag",29]</code>|= EXAMPLE1  
|x1= <code>_wsPlayer = [[weaponState]] [[player]]; // ["arifle_MXC_ACO_F","arifle_MXC_ACO_F","Single","30Rnd_65x39_caseless_mag",30]</code>|= EXAMPLE1  
|x2= <code>_wsVehiclePlayer <nowiki>=</nowiki> [[weaponState]] <nowiki>[</nowiki>[[vehicle]] [[player]],[0]]; //["M256","M256","M256","20Rnd_120mmSABOT_M1A2",20] </code>|= EXAMPLE2  
|x2= <code>_wsVehicle = [[weaponState]] [_apc, [0]]; // ["autocannon_40mm_CTWS","HE","player","60Rnd_40mm_GPR_Tracer_Red_shells",60]</code>|= EXAMPLE2  
|x3= <code>_SecondPositionOfThefirstTurret <nowiki>=</nowiki> [[weaponState]] <nowiki>[</nowiki>[[vehicle]] [[player]],[0,0,1]]; </code>|= EXAMPLE2
|x3= <code>_wsVehicle = [[weaponState]] [_apc, [0], "AP"]; // ["autocannon_40mm_CTWS","AP","player","40Rnd_40mm_APFSDS_Tracer_Red_shells",40]</code>|= EXAMPLE3
 
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 19:50, 13 February 2017

Hover & click on the images for description

Description

Description:
Returns the currently selected weapon state for unit or vehicle.

Since Arma 3 v1.67.140397 this command has been improved and extended:
  • It is now possible to query any weapon of a vehicle without the need to place a weapon operator first, provided the weapon or muzzle is specified in optional param. By default a vehicle has no weapons selected, so querying currently selected weapon returns no weapon, unless weapon is specified.
  • Driver turret can now be accessed as well with turret path [-1].
  • Muzzle name is supported as well as weapon name. Weapon search gets priority, but if there is no weapon with such name, the muzzle will be selected.
Groups:
Uncategorised

Syntax

Syntax:
weaponState unit
Parameters:
unit: Object
Return Value:
Array - in format [weapon, muzzle, firemode, magazine, ammoCount], where:

Alternative Syntax

Syntax:
weaponState [vehicle, turretPath, weapon]
Parameters:
[vehicle, turretPath, weapon]: Array
vehicle: Object
turretPath: Array
weapon (Optional): String (since Arma 3 v1.69.140397) - weapon or muzzle name
Return Value:
Array - in format [weapon, muzzle, firemode, magazine, ammoCount], where:

Examples

Example 1:
_wsPlayer = weaponState player; // ["arifle_MXC_ACO_F","arifle_MXC_ACO_F","Single","30Rnd_65x39_caseless_mag",30]
Example 2:
_wsVehicle = weaponState [_apc, [0]]; // ["autocannon_40mm_CTWS","HE","player","60Rnd_40mm_GPR_Tracer_Red_shells",60]
Example 3:
_wsVehicle = weaponState [_apc, [0], "AP"]; // ["autocannon_40mm_CTWS","AP","player","40Rnd_40mm_APFSDS_Tracer_Red_shells",40]

Additional Information

See also:
weaponsselectWeaponTurretloadMagazinemagazinesTurretweaponsTurret

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

Bottom Section