weaponsItems: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(85 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 0.76


|0.76|= Game version
|gr1= Unit Inventory
____________________________________________________________________________________________


| Returns an array with subarrays contains class names and also names of connected items of all the vehicle's weapons.<br/>
|gr2= Vehicle Inventory
Since Arma 3 v1.21.124406 it is possible to query weapon holders and ammo crates with this command. |= Description
____________________________________________________________________________________________


| '''weaponsItems''' vehicle |= Syntax
|descr= [[File:Weaponsitems.jpg|150px|right|border]]Returns an array with subarrays contains class names and also names of connected items of all the vehicle's weapons.
{{Feature|informative|This command will return weapon magazines as well in , or empty array [] if weapon has no magazine}}
* {{GVI|arma3|1.22|size= 0.75}} it is possible to query weapon holders and ammo crates with this command.<br><!--
-->If the argument is a vehicle, the command will return vehicle's weapons.<br><!--
-->If the argument is a container, the command will act identical to [[weaponsItemsCargo]].
* {{GVI|arma3|1.96|size= 0.75}} the returned array always contains secondary muzzle magazine info and consistent with [[getUnitLoadout]] format for weapon items.
* {{GVI|arma3|2.02|size= 0.75}} the returned array can contains binocular weapon items.


|p1= vehicle: [[Object]] - unit or vehicle |= Parameter 1
|s1= [[weaponsItems]] vehicle


| [[Array]] |= RETURNVALUE
|p1= vehicle: [[Object]] - unit or vehicle


|r1= [[Array]] of [[Array]]s of weapon items, format [weapon, muzzle, flashlight, optics, [magazine, ammo], [magazine, ammo], bipod]:
* weapon: [[String]]
* muzzle: [[String]]
* flashlight: [[String]]
* optics: [[String]]
* [primaryMagazine, primaryAmmo]: [[Array]] - could be empty
* [secondaryMagazine, secondaryAmmo]: [[Array]] - could be empty
* bipod: [[String]]
{{Feature|important|The weapons are listed in the order they were taken by the unit, with the most recent at the bottom of the array, e.g do '''not''' assume the first item is always the primary weapon.}}


|x1= <code>[[hint]] [[str]] [[weaponsItems]] [[player]];</code>
|s2= [[weaponsItems]] [vehicle, extended]
[[Image:Weaponsitems.jpg|200px|right|border]]
|s2since= arma3 2.14
<code>[
 
[ //=PRIMARY=
|p21= vehicle: [[Object]] - unit or vehicle
"arifle_MX_ACO_pointer_F", //weapon
|p22= extended: [[Boolean]] - [[true]] to include muzzle information
"muzzle_snds_H", //suppressor
 
"acc_pointer_IR", //laser
|r2= [[Array]] of [[Array]]s (see above) in format [weapon, muzzle, flashlight, optics, [magazine, ammo, muzzle, maxammo], [magazine, ammo, muzzle, maxammo], bipod]
"optic_Aco", //optics
 
[ //loaded magazine
|x1= <sqf>
"30Rnd_65x39_caseless_mag", //mag type
hint str weaponsItems player;
30 //mag ammo count
// returns e.g
]
/*
],
[
[ //=SECONDARY=
["arifle_MX_ACO_pointer_F", "muzzle_snds_H", "acc_pointer_IR", "optic_Aco", ["30Rnd_65x39_caseless_mag", 30], [], "bipod_01_F_blk"],
"launch_NLAW_F",
["launch_NLAW_F", "", "", "", ["NLAW_F", 1], [], ""],
"",
["hgun_P07_F", "muzzle_snds_L", "", "", ["16Rnd_9x21_Mag", 11], [], ""]
"",
]
"",
// a loaded underbarrel grenade launcher can look like this:
[
[
"NLAW_F",
["arifle_MX_GL_F", "muzzle_snds_H", "acc_pointer_IR", "optic_Aco", ["30Rnd_65x39_caseless_mag", 30], ["1Rnd_HE_Grenade_shell", 1], ""]
1
]
],
[ //=HANDGUN=
"hgun_P07_F",
"muzzle_snds_L",
"",
"",
[
"16Rnd_9x21_Mag",
11
]
]
]
]
</code>
*/
|= EXAMPLE1


|x2= <code>[[hint]] [[str]] [[weaponsItems]] [[vehicle]] [[player]];</code>
</sqf>


<code>[
|x2= <sqf>
[
hint str weaponsItems vehicle player;
"gatling_30mm",
// returns e.g
"",
/*
"",
[
"",
["gatling_30mm", "", "", "", ["250Rnd_30mm_HE_shells", 250], [], ""],
[
["missiles_SCALPEL", "", "", "", ["8Rnd_LG_scalpel", 8], [], ""],
"250Rnd_30mm_HE_shells",
["rockets_Skyfire", "", "", "", ["38Rnd_80mm_rockets", 38], [], ""]
250
]
],
[
"missiles_SCALPEL",
"",
"",
"",
[
"8Rnd_LG_scalpel",
8
]
],
[
"rockets_Skyfire",
"",
"",
"",
[
"38Rnd_80mm_rockets",
38
]
]
]
]
</code>
*/
|= EXAMPLE2
</sqf>
____________________________________________________________________________________________


| [[weaponsItemsCargo]], [[primaryWeaponItems]], [[secondaryWeaponItems]], [[handgunItems]], [[addPrimaryWeaponItem]], [[addSecondaryWeaponItem]], [[addHandgunItem]], [[primaryWeapon]], [[secondaryWeapon]], [[handgunWeapon]] |= SEEALSO
|seealso= [[weaponsItemsCargo]] [[primaryWeaponItems]] [[secondaryWeaponItems]] [[handgunItems]] [[addPrimaryWeaponItem]] [[addSecondaryWeaponItem]] [[addHandgunItem]] [[primaryWeapon]] [[secondaryWeapon]] [[handgunWeapon]] [[binocular]] [[weaponAccessories]] [[addWeaponWithAttachmentsCargoGlobal]] [[BIS_fnc_weaponComponents]] [[weaponState]]
 
|  |= MPBEHAVIOUR
____________________________________________________________________________________________
}}
}}
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on August 17, 2013
<dt class="note">[[User:AgentRev01|AgentRev]]<dd class="note">
Be careful with this function. The weapons are listed in the order they were taken by the unit, with the most recent at the bottom of the array. Therefore, do not assume the first one is always the primary weapon, and so on.
Also, here's how the primary weapon looks if it has a grenade launcher with a loaded grenade:<br/>
<br/>
<code>[
"arifle_MX_GL_F",
"muzzle_snds_H",
"acc_pointer_IR",
"optic_Aco",
[
"30Rnd_65x39_caseless_mag",
30
],
[
"1Rnd_HE_Grenade_shell",
1
]
]</code>
<!-- Note Section END -->
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Weapons|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on October 25, 2014 - 01:45 (UTC)</dd>
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt>
<dd class="note">
The output of this command is an array of arrays and is as follows: (If the unit only has 1 weapon, output is an array within an array.)
<code>[
[
((_arr select 0) select 0) //STRING - The weapon's classname
((_arr select 0) select 1) //STRING - Classname of the unit's equipped 'Muzzle/Barrel Accessory'
((_arr select 0) select 2) //STRING - Classname of the unit's equipped 'Side Accessory'
((_arr select 0) select 3) //STRING - Classname of the unit's equipped 'Top/Optic Accessory'
((_arr select 0) select 4) //ARRAY - Magazine information
[
(((_arr select 0) select 4) select 0) //STRING - Classname of the loaded magazine
(((_arr select 0) select 4) select 1) //SCALAR(Number) - Amount of bullets in the mag
]
] //If unit has more than one weapon, the output will follow the same pattern as above except with a new element
]</code><br>
If you use this command on a unit that does not have a magazine loaded, the array containing magazine info is not included (_this select 4). Sample output with running "hint str weaponsItems player;" '''after''' manually removing the magazines from the weapons.<br>Tested with "B_Soldier_F".
<code>[
[
"arifle_MX_ACO_pointer_F",
"",
"acc_pointer_IR",
"optic_Aco"
],
[
"hgun_P07_F",
"",
"",
""
]
]</code><br>
You can use this code to easily check if an array element exists (note the curly brackets indicating a "code" type):
<code>if (isNil {_weaponsItemsOutput select 4}) then {hint "No magazine is loaded";}</code><br>
This command returns an empty array if the unit has no weapons equipped.<br>
All of this was tested in '''A3 1.32.127785'''
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 19:11, 15 March 2024

Hover & click on the images for description

Description

Description:
Weaponsitems.jpg
Returns an array with subarrays contains class names and also names of connected items of all the vehicle's weapons.
This command will return weapon magazines as well in , or empty array [] if weapon has no magazine
  • Arma 3 logo black.png1.22 it is possible to query weapon holders and ammo crates with this command.
    If the argument is a vehicle, the command will return vehicle's weapons.
    If the argument is a container, the command will act identical to weaponsItemsCargo.
  • Arma 3 logo black.png1.96 the returned array always contains secondary muzzle magazine info and consistent with getUnitLoadout format for weapon items.
  • Arma 3 logo black.png2.02 the returned array can contains binocular weapon items.
Groups:
Unit InventoryVehicle Inventory

Syntax

Syntax:
weaponsItems vehicle
Parameters:
vehicle: Object - unit or vehicle
Return Value:
Array of Arrays of weapon items, format [weapon, muzzle, flashlight, optics, [magazine, ammo], [magazine, ammo], bipod]:
The weapons are listed in the order they were taken by the unit, with the most recent at the bottom of the array, e.g do not assume the first item is always the primary weapon.

Alternative Syntax

Syntax:
weaponsItems [vehicle, extended]
Parameters:
vehicle: Object - unit or vehicle
extended: Boolean - true to include muzzle information
Return Value:
Array of Arrays (see above) in format [weapon, muzzle, flashlight, optics, [magazine, ammo, muzzle, maxammo], [magazine, ammo, muzzle, maxammo], bipod]

Examples

Example 1:
hint str weaponsItems player; // returns e.g /* [ ["arifle_MX_ACO_pointer_F", "muzzle_snds_H", "acc_pointer_IR", "optic_Aco", ["30Rnd_65x39_caseless_mag", 30], [], "bipod_01_F_blk"], ["launch_NLAW_F", "", "", "", ["NLAW_F", 1], [], ""], ["hgun_P07_F", "muzzle_snds_L", "", "", ["16Rnd_9x21_Mag", 11], [], ""] ] // a loaded underbarrel grenade launcher can look like this: [ ["arifle_MX_GL_F", "muzzle_snds_H", "acc_pointer_IR", "optic_Aco", ["30Rnd_65x39_caseless_mag", 30], ["1Rnd_HE_Grenade_shell", 1], ""] ] */
Example 2:
hint str weaponsItems vehicle player; // returns e.g /* [ ["gatling_30mm", "", "", "", ["250Rnd_30mm_HE_shells", 250], [], ""], ["missiles_SCALPEL", "", "", "", ["8Rnd_LG_scalpel", 8], [], ""], ["rockets_Skyfire", "", "", "", ["38Rnd_80mm_rockets", 38], [], ""] ] */

Additional Information

See also:
weaponsItemsCargo primaryWeaponItems secondaryWeaponItems handgunItems addPrimaryWeaponItem addSecondaryWeaponItem addHandgunItem primaryWeapon secondaryWeapon handgunWeapon binocular weaponAccessories addWeaponWithAttachmentsCargoGlobal BIS_fnc_weaponComponents weaponState

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