I noticed following problem when using setUnitLoadout command.
When more than 1 magazine have same number of bullets (but less than maximum magazine capacity),
this command will not set given bullet count, instead added mags will be fully loaded to its maximum capacity.
Description
Details
- Severity
- Minor
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 10
- Category
- Scripting
execute following
player setUnitLoadout [[],[],[],[],["V_Chestrig_rgr",[["30Rnd_556x45_Stanag",15,3]]],[],"","",[],["","","","","",""]]
This command should give 15 mags with 3 bullets each. It will give 15 full mags instead.
NOTICE!!!!! Adding one magazine will work fine.
player setUnitLoadout [[],[],[],[],["V_Chestrig_rgr",[["30Rnd_556x45_Stanag",15,1]]],[],"","",[],["","","","","",""]]
Huge thanks to BIS!
With this command, one can add deferent items/mags/weps/... to bag/vest/unifrom/... by simply pushBack correct item array to corresponding container array.
Hopefully this command will be fixed, as it is THE VERY BEST item handling command ever!!!
I personally love, how this command handles wrong input and empty arrays, so much more flexible from addMagazine, addItem and others.
Great work BIS! :)
Status | Assigned | Task | ||
---|---|---|---|---|
Feedback | None | T119475 setUnitLoadout mess ammocount | ||
Duplicate | None | T172712 Please fix this! Cant be that hard |
Event Timeline
while we waiting for the fix, here a simple solution (as long as you are interest in restore or copy a loadout):
Ux_fnc_getUnitLoadout = { private _magazines_config = configFile >> "CfgMagazines"; private _fnc_fixContainerData = { if (count _this == 0) exitWith {}; private _items = _this select 1; if (count _items == 0) exitWith {}; private _new_items = []; { private _item_count = _x select 1; if (count _x == 3 && _item_count > 1) then { private _type = _x select 0; private _ammo_count = _x select 2; private _mag_size = getNumber(_magazines_config >> _type >> "count"); if (_ammo_count < _mag_size) then { private _n = 0; while { _n < _item_count } do { _new_items pushBack [_type, 1, _ammo_count]; _n = _n + 1; }; } else { _new_items pushBack _x; }; } else { _new_items pushBack _x; }; } forEach _items; _this set [1, _new_items]; }; private _loadout = getUnitLoadout _this; (_loadout select 3) call _fnc_fixContainerData; (_loadout select 4) call _fnc_fixContainerData; (_loadout select 5) call _fnc_fixContainerData; _loadout; };
This is a replacement for getUnitLoadout, it just reforms the array so
[["30Rnd_556x45_Stanag",2,15]]
becomes
[["30Rnd_556x45_Stanag",1,15],["30Rnd_556x45_Stanag",1,15]]
which then dont trigger the error in setUnitLoadout
Example:
savedLoadout = player call Ux_fnc_getUnitLoadout; player setUnitLoadout [savedLoadout, false];