Advertisement
Guest User

Arma 3 - util_cleanLoadout / Fix setUnitLoadout Ammo Bug

a guest
Oct 23rd, 2020
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.86 KB | None | 0 0
  1. /**
  2.  * util_cleanLoadout
  3.  * _loadout = (player getUnitLoadout) call util_cleanLoadout;
  4.  *
  5.  * Keeps the ammo from refilling if there are duplicate used ammo counts in one inventory container. Fix for what demellion posted
  6.  */
  7.  
  8. private ["_loadout", "_uniform", "_type", "_vest", "_backpack"];
  9.  
  10. _loadout = _this;
  11.  
  12. _uniform = ((_loadout select 3) select 1);
  13. {
  14.     _type = (_x select 0) call BIS_fnc_itemType;
  15.     if (((_type select 1) isEqualTo "Bullet") && {(_x select 1) >= 2 && {(_x select 2) != (getNumber(configFile >> "cfgMagazines" >> (_x select 0) >> "count"))}}) then
  16.     {
  17.         ((_loadout select 3) select 1) set [_forEachIndex, [(_x select 0),1,(_x select 2)]];
  18.         for "_i" from 1 to (_x select 1)-1 do
  19.         {
  20.             ((_loadout select 3) select 1) pushBack [(_x select 0),1,(_x select 2)];
  21.         };
  22.     };
  23. } forEach _uniform; //check uniform
  24.  
  25. _vest = ((_loadout select 4) select 1);
  26. {
  27.     _type = (_x select 0) call BIS_fnc_itemType;
  28.     if (((_type select 1) isEqualTo "Bullet") && {(_x select 1) >= 2 && {(_x select 2) != (getNumber(configFile >> "cfgMagazines" >> (_x select 0) >> "count"))}}) then
  29.     {
  30.         ((_loadout select 4) select 1) set [_forEachIndex, [(_x select 0),1,(_x select 2)]];
  31.         for "_i" from 1 to (_x select 1)-1 do
  32.         {
  33.             ((_loadout select 4) select 1) pushBack [(_x select 0),1,(_x select 2)];
  34.         };
  35.     };
  36. } forEach _vest; //check vest
  37.  
  38. _backpack = ((_loadout select 5) select 1);
  39. {
  40.     _type = (_x select 0) call BIS_fnc_itemType;
  41.     if (((_type select 1) isEqualTo "Bullet") && {(_x select 1) >= 2 && {(_x select 2) != (getNumber(configFile >> "cfgMagazines" >> (_x select 0) >> "count"))}}) then
  42.     {
  43.         ((_loadout select 5) select 1) set [_forEachIndex, [(_x select 0),1,(_x select 2)]];
  44.         for "_i" from 1 to (_x select 1)-1 do
  45.         {
  46.             ((_loadout select 5) select 1) pushBack [(_x select 0),1,(_x select 2)];
  47.         };
  48.     };
  49. } forEach _backpack; //check backpack
  50.  
  51. _loadout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement