Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.24

Description

Description:Return information about the currently selected weapon for a unit or vehicle turret:
  1. weaponName: Class name of current weapon (e.g. "VBS2_US_m4a1_acog_peq2a_m203")
  2. muzzleName: Class name of current muzzle (e.g. "vbs2_M203_Muzzle")
  3. modeName: Selected firing mode (e.g. "Single" or "Auto")
  4. magazineName: Class name of current magazine (e.g. "vbs2_mag_40mm_HE_m203")
  5. ammoCount: Rounds left for current magazine
  6. nextMagazine: Class name of magazine that will be loader after the currently loaded round is fired. (V1.50+)

    In V2.12+ the following properties are returned as well:

  7. 'weaponType: Number indicating the type parameter (see Weapon Configuration in the VBS Developer Reference) of the weapon (e.g. 1 for primary, 2 for handgun)
  8. 'weaponWeight: Weight of weapon (in kg)
  9. 'magazineType: Number indicating the type parameter (see Weapon Configuration in the VBS Developer Reference)
  10. of the weapon (e.g. 256 for primary magazine, 16 for handgun magazine)
  11. 'magazineWeight: Weight of magazine (in kg)
  12. 'magazineAmmoSimulation: Number indicating the ammunition simulation parameter (see Magazine Configuration in the VBS Developer Reference). The correlations of the returned number and the property's string value are as follows:
    • "" = AmmoNone = 0
    • "shotShell" = AmmoShotShell = 1
    • "shotMissile" = AmmoShotMissile = 2
    • "shotRocket" = AmmoShotMissile = 2
    • "shotRocket" = AmmoShotRocket = 3 (deprecated)
    • "shotBullet" = AmmoShotBullet = 4
    • "shotSpread" = AmmoShotSpread = 5
    • "shotIlluminating" = AmmoShotIlluminating = 6
    • "shotSmoke" = AmmoShotSmoke = 7
    • "shotTimeBomb" = AmmoShotTimeBomb = 8
    • "shotPipeBomb" = AmmoShotPipeBomb = 9
    • "shotMine" = AmmoShotMine = 10
    • "shotStroke" = AmmoShotStroke = 11
    • "laserDesignate" = AmmoShotLaser = 12
    • "shotcm" = AmmoShotCM = 13
    • "shotNVGMarker" = AmmoShotMarker = 14

Syntax

Syntax:weaponState unit
Parameters:
  • unit: Object - Unit for which the weapon state is returned. (V1.40: only works for player, not for AI)
Return Value:Array - see description

Alternative Syntax

Syntax:weaponState [vehicle, turretPath]
Parameters:
  • vehicle: Object - Vehicle on which turret is located.
  • turretPath: Array - Turret for which the weapon state is returned.
Return Value:Array - see description

Examples

Examples:
_state = weaponState player
_state = weaponState [vehicle player, [0]]

Additional Information

See also: setWeaponState, reloadState, ammo, magazines, weapons, currentMagazine, currentMuzzle, currentWeapon, currentWeaponMode
Multiplayer:
Problems:

Notes






To grab the currently selected weapon from a vehicle without a turret, use this workaround: _

ctrltext (findDisplay 300 displayCtrl 118)

To check whether a certain weapon is currently selected, use:

_nameOfYourWeapon = "vbs2_MaverickLauncher";
ctrltext (findDisplay 300 displayCtrl 118) == getText (configFile >> "CfgWeapons" >> _nameOfYourWeapon >> "Displayname")
Julian saenger 08:10, 18 October 2011 (PDT)