magazinesDetailBackpack: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
No edit summary
Line 48: Line 48:


|seealso= [[magazinesDetail]], [[magazinesDetailUniform]], [[magazinesDetailVest]]
|seealso= [[magazinesDetail]], [[magazinesDetailUniform]], [[magazinesDetailVest]]
}}
{{Note
|user= Leopard20
|timestamp= 20210912220755
|text= To return the ammo count in each magazine, you can use this code:
<code>[[magazinesDetail]] [[player]] [[apply]] {
    [[private]] _i1 [[=]] (_x [[find]] "Mag(") + 4;
    [[if]] (_i1 [[<]] 4) [[then]] { {{cc|return 1 for mags like grenades, chemlights, etc.}}
        1;
    } else {
        [[private]] _i2 [[=]] _x [[find]] ["/", _id1];
        [[parseNumber]] (_x [[select]] [_i1, _i2 - _i1]); {{cc|return cnt}}
    };
};</code>
}}
}}

Revision as of 23:07, 12 September 2021

Hover & click on the images for description

Description

Description:
Returns an array with the type names of all the unit's backpack magazines.
Groups:
Unit Inventory

Syntax

Syntax:
magazinesDetailBackpack unit
Parameters:
unit: Object
Return Value:
Array

Alternative Syntax

Syntax:
magazinesDetailBackpack [unit, includeEmpty]
Parameters:
unit: Object - unit
includeEmpty: Boolean - (Optional, default false) true to include empty magazines
Return Value:
Array

Examples

Example 1:
magazinesDetailBackpack player; /* [ "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000011/2]", "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000012/2]", "Chemlight (Green)(1/1)[id/cr:10000027/2]", "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000013/2]", "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000014/2]", "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000015/2]", "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000016/2]", "6.5 mm 30Rnd Sand Mag(30/30)[id/cr:10000017/2]", "9 mm 16Rnd Mag(16/16)[id/cr:10000019/2]", "9 mm 16Rnd Mag(16/16)[id/cr:10000020/2]", "RGO Grenade(1/1)[id/cr:10000021/2]", "RGO Grenade(1/1)[id/cr:10000022/2]", "IR Grenade [NATO](1/1)[id/cr:10000023/2]", "IR Grenade [NATO](1/1)[id/cr:10000024/2]", "Smoke Grenade (White)(1/1)[id/cr:10000025/2]", "Smoke Grenade (Green)(1/1)[id/cr:10000026/2]", "Chemlight (Green)(1/1)[id/cr:10000028/2]" ] */

Additional Information

See also:
magazinesDetailmagazinesDetailUniformmagazinesDetailVest

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
Leopard20 - c
Posted on Sep 12, 2021 - 22:07 (UTC)
To return the ammo count in each magazine, you can use this code: magazinesDetail player apply { private _i1 = (_x find "Mag(") + 4; if (_i1 [[<]] 4) then { // return 1 for mags like grenades, chemlights, etc. 1; } else { private _i2 = _x find ["/", _id1]; parseNumber (_x select [_i1, _i2 - _i1]); // return cnt }; };