Advertisement
Guest User

Untitled

a guest
Jan 25th, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 3.01 KB | None | 0 0
  1. span class="re5"> TLC_container_add =
  2. {
  3.     params [
  4.         ["_container",objNull,[objNull]],
  5.         ["_item","",[""]],
  6.         ["_count",1,[0]],
  7.         ["_bulletCount",-1,[0]]
  8.     ];
  9.  
  10.     if (isNull _container) exitWith {false};
  11.     if ((_item) isEqualTo ("")) exitWith {false};
  12.     if (_count <= 0) exitWith {false};
  13.  
  14.     private _itemInfo = [_item] call TLC_functions_itemDetails;
  15.     if ((_itemInfo) isEqualTo ([])) exitWith {false};
  16.  
  17.     private _cargo = [_container] call TLC_container_serialize;
  18.     _cargo params ["_weapCargo","_magCargo","_itemCargo","_bpCargo"];
  19.  
  20.     private _added = false;
  21.     private _index = -1;
  22.  
  23.     switch (_itemInfo # 5) do {
  24.         case "Weapon":
  25.         {
  26.             _index = [_item,_weapCargo] call TLC_functions_index;
  27.  
  28.             if ((_index) isEqualTo (-1)) then {
  29.                 _weapCargo pushBack [_item,_count];
  30.             } else {
  31.                 (_weapCargo # _index) set [1,_weapCargo # _index # 1 + _count];
  32.             };
  33.  
  34.             _added = true;
  35.         };
  36.  
  37.         case "Mine",
  38.         case "Magazine":
  39.         {
  40.             if ((_bulletCount) isEqualTo (-1)) then {
  41.                 _bulletCount = getNumber(configfile >> "CfgMagazines" >> _item >> "count");
  42.             };
  43.  
  44.             {
  45.                 if ((_x # 0) isEqualTo (_item) && (_x # 2) isEqualTo (_bulletCount)) exitWith {
  46.                     _index = _forEachIndex;
  47.                 };
  48.             } forEach _magCargo;
  49.  
  50.             if ((_index) isEqualTo (-1)) then {
  51.                 _magCargo pushBack [_item,_count,_bulletCount];
  52.             } else {
  53.                 (_magCargo # _index) set [1,_magCargo # _index # 1 + _count];
  54.             };
  55.  
  56.             _container addMagazineAmmoCargo [_item,_count,_bulletCount];
  57.  
  58.             if (_itemInfo # 6 in ["Grenade","SmokeShell"]) then {
  59.                 if !(isNull objectParent _container) then {
  60.                     (objectParent _container) addMagazine ["FixGrenade",1];
  61.                 } else {
  62.                     LOG("Not a player")
  63.                 };
  64.             };
  65.             _added = true;
  66.         };
  67.  
  68.         default
  69.         {
  70.             if ((_itemInfo # 6) isEqualTo ("Backpack")) then {
  71.                 _index = [_item,_bpCargo] call TLC_functions_index;
  72.  
  73.                 if ((_index) isEqualTo (-1)) then {
  74.                     _bpCargo pushBack [_item,_count];
  75.                 } else {
  76.                     (_bpCargo # _index) set [1,_bpCargo # _index # 1 + _count];
  77.                 };
  78.  
  79.                 _added = true;
  80.             } else {
  81.                 _index = [_item,_itemCargo] call TLC_functions_index;
  82.  
  83.                 if ((_index) isEqualTo (-1)) then {
  84.                     _itemCargo pushBack [_item,_count];
  85.                 } else {
  86.                     (_itemCargo # _index) set [1,_itemCargo # _index # 1 + _count];
  87.                 };
  88.                 _added = true;
  89.             };
  90.         };
  91.     };
  92.  
  93.     if (_added) then {
  94.         _container setVariable ["tlCargo",_cargo,true];
  95.     };
  96.  
  97.     _added
  98. };
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement