weaponsInfo: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) (Created page with "{{RV|type=command |game1= arma3 |version1= 2.10 |branch= dev |gr1= Weapons |descr= Returns entitiy's weapons information including weapon index and firemode. |s1= unit w...") |
Killzone Kid (talk | contribs) No edit summary |
||
Line 26: | Line 26: | ||
* ammoCount: [[Number]] - magazine ammo count or -1 | * ammoCount: [[Number]] - magazine ammo count or -1 | ||
|x1= <code>[[private]] _weapons = [[player]] [[weaponsInfo]] <nowiki>[</nowiki>[[currentWeapon]] [[player]], [[true]]]; | |x1= Find weapon with FullAuto firemode and switch to it: <code>[[private]] _weapons = [[player]] [[weaponsInfo]] <nowiki>[</nowiki>[[currentWeapon]] [[player]], [[true]]]; | ||
[[private]] _found = _weapons [[findIf]] { _x [[select]] 4 == "FullAuto" }; | [[private]] _found = _weapons [[findIf]] { _x [[select]] 4 == "FullAuto" }; | ||
[[if]] (_found > -1) [[then]] { [[action]] ["SwitchWeapon", [[player]], [[player]], _weapons [[select]] _found [[select]] 0] };</code> | [[if]] (_found > -1) [[then]] { [[action]] ["SwitchWeapon", [[player]], [[player]], _weapons [[select]] _found [[select]] 0] };</code> |
Revision as of 07:57, 30 March 2022
Description
- Description:
- Returns entitiy's weapons information including weapon index and firemode.
- Groups:
- Weapons
Syntax
- Syntax:
- unit weaponsInfo [weapon, onlyLoaded]
- Parameters:
- unit: Object - person
- weapon: String - name of the weapon (not muzzle) or "" to return all weapons
- onlyLoaded (Optional): Boolean - true to return loaded weapons only. Default false.
- Return Value:
- Array - weapons information in format [weaponIndex, isSelected, weaponName, muzzleName, firemode, magazineName, ammoCount] where:
- weaponIndex: Number - internal weapon index (changes frequently) used with "SwitchWeapon" and "UseWeapon" actions
- isSelected: Boolean - true if this weapon is currently selected
- weaponName: String - weapon name
- muzzleName: String - muzzle name
- firemode: String - firemode that is set for this 'weaponIndex'
- magazineName: String - name of the loaded magazine or ""
- ammoCount: Number - magazine ammo count or -1
Examples
- Example 1:
- Find weapon with FullAuto firemode and switch to it:
private _weapons = player weaponsInfo [currentWeapon player, true]; private _found = _weapons findIf { _x select 4 == "FullAuto" }; if (_found > -1) then { action ["SwitchWeapon", player, player, _weapons select _found select 0] };
Additional Information
- See also:
- weaponState weaponReloadingTime
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