Jump to content

setUnitLoadout mess ammocount

Recommended Posts



Posting here coz cant get in new feedback tracker  :(



Public (non-dev) 1.62.137494



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.



Try execute following

player setUnitLoadout [[],[],[],[],["V_Chestrig_rgr",[["30Rnd_556x45_Stanag",15,3]]],[],"","",[],["","","","","",""]]

This command should give 3 mags with 15 bullets each. It will give 3 full mags instead.





Adding one magazine will work fine.

player setUnitLoadout [[],[],[],[],["V_Chestrig_rgr",[["30Rnd_556x45_Stanag",15,1]]],[],"","",[],["","","","","",""]]


There is also a nasty workaround

player setUnitLoadout [[],[],[],[],["V_Chestrig_rgr",[["30Rnd_556x45_Stanag",15,1],["30Rnd_556x45_Stanag",15,1]]],[],"","",[],["","","","","",""]]

This will give two semi-filled magazines.

But this is not very usable, because getUnitLoadout will combine similar mags with same ammo count.



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! :)

Share this post

Link to post
Share on other sites

A little work around to respawn with the same loadout as when dying (all ammo in all magazines are saved).


{_x addMPEventHandler ["MPkilled", {
_unit = _this select 0;

if (!isPlayer _unit) exitWith {removeSwitchableUnit _unit}; // optional

[_unit, [missionNamespace, format ["cur_inv_%1", _unit getVariable "invKill"]]] call BIS_fnc_saveInventory;
_unit setVariable ["MGI_ammo1",_unit ammo (primaryWeapon _unit)];
_unit setVariable ["MGI_ammo2",_unit ammo (handgunWeapon _unit)];
_unit setVariable ["MGI_ammo3",_unit ammo (secondaryWeapon _unit)];
_unit setVariable ["MGI_mags",magazinesAmmoFull _unit];
_unit setVariable ["MGI_weapon",currentWeapon _unit];

}]} forEach playableUnits + switchableUnits;

{_x addMPEventHandler ["MPRespawn", {
_unit = _this select 0;
_corpse = _this select 1;
if (!isPlayer _unit) exitWith {deleteVehicle _unit}; // optional

[_unit, [missionNamespace, format ["cur_inv_%1", _unit getVariable "invKill"]]] call BIS_fnc_loadInventory;
{_unit removeMagazine _x} forEach magazines _unit;
_unit setAmmo [primaryWeapon _unit, 0];
_unit setAmmo [handGunWeapon _unit, 0];
_unit setAmmo [secondaryWeapon _unit, 0];
{ if (((_unit getVariable "MGI_mags") select _foreachindex select 3) <= 0) then {_unit addMagazine [_x select 0,_x select 1]}} forEach (_unit getVariable "MGI_mags");
_unit setAmmo [primaryWeapon _unit,_unit getVariable "MGI_ammo1"];
_unit setAmmo [handGunWeapon _unit,_unit getVariable  "MGI_ammo2"];
_unit setAmmo [secondaryWeapon _unit,_unit getVariable "MGI_ammo3"];
_unit selectWeapon (_unit getVariable "MGI_weapon");

removeAllWeapons _corpse;
removeBackpackGlobal _corpse;
removeVest _corpse;
removeAllAssignedItems _corpse;
removeAllItems _corpse;
removeGoggles _corpse;
removeHeadgear _corpse;
{deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];

}]} forEach playableUnits + switchableUnits;

Share this post

Link to post
Share on other sites

@pierremgi, thanks but, this is troubleshooting report, i just inform BIS about semi-broken command.


However, this script clearly show how complicated loadout manipulations are at the moment.

several commands for each item slot, multiply addMagazine commands introduced from OFP to A2:OA.

Hopefully, we will have get/setUnitLoadout as primary gear manipulation method.


By the way, notice how classic addMagazine used to add empty mag. This is in fact one of very few ways to add empty mag to players inventory.

Other way is setUnitLoadout.


BIS, please make this command as simple as possible. Please do not overextend with command`s input control,

it is better to have less protection then less flexibility.

Share this post

Link to post
Share on other sites

BIS, please take a look at this problem, it does not look like too big of a problem. Is it?

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now