Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- span class="re5"> TLC_container_add =
- {
- params [
- ["_container",objNull,[objNull]],
- ["_item","",[""]],
- ["_count",1,[0]],
- ["_bulletCount",-1,[0]]
- ];
- if (isNull _container) exitWith {false};
- if ((_item) isEqualTo ("")) exitWith {false};
- if (_count <= 0) exitWith {false};
- private _itemInfo = [_item] call TLC_functions_itemDetails;
- if ((_itemInfo) isEqualTo ([])) exitWith {false};
- private _cargo = [_container] call TLC_container_serialize;
- _cargo params ["_weapCargo","_magCargo","_itemCargo","_bpCargo"];
- private _added = false;
- private _index = -1;
- switch (_itemInfo # 5) do {
- case "Weapon":
- {
- _index = [_item,_weapCargo] call TLC_functions_index;
- if ((_index) isEqualTo (-1)) then {
- _weapCargo pushBack [_item,_count];
- } else {
- (_weapCargo # _index) set [1,_weapCargo # _index # 1 + _count];
- };
- _added = true;
- };
- case "Mine",
- case "Magazine":
- {
- if ((_bulletCount) isEqualTo (-1)) then {
- _bulletCount = getNumber(configfile >> "CfgMagazines" >> _item >> "count");
- };
- {
- if ((_x # 0) isEqualTo (_item) && (_x # 2) isEqualTo (_bulletCount)) exitWith {
- _index = _forEachIndex;
- };
- } forEach _magCargo;
- if ((_index) isEqualTo (-1)) then {
- _magCargo pushBack [_item,_count,_bulletCount];
- } else {
- (_magCargo # _index) set [1,_magCargo # _index # 1 + _count];
- };
- _container addMagazineAmmoCargo [_item,_count,_bulletCount];
- if (_itemInfo # 6 in ["Grenade","SmokeShell"]) then {
- if !(isNull objectParent _container) then {
- (objectParent _container) addMagazine ["FixGrenade",1];
- } else {
- LOG("Not a player")
- };
- };
- _added = true;
- };
- default
- {
- if ((_itemInfo # 6) isEqualTo ("Backpack")) then {
- _index = [_item,_bpCargo] call TLC_functions_index;
- if ((_index) isEqualTo (-1)) then {
- _bpCargo pushBack [_item,_count];
- } else {
- (_bpCargo # _index) set [1,_bpCargo # _index # 1 + _count];
- };
- _added = true;
- } else {
- _index = [_item,_itemCargo] call TLC_functions_index;
- if ((_index) isEqualTo (-1)) then {
- _itemCargo pushBack [_item,_count];
- } else {
- (_itemCargo # _index) set [1,_itemCargo # _index # 1 + _count];
- };
- _added = true;
- };
- };
- };
- if (_added) then {
- _container setVariable ["tlCargo",_cargo,true];
- };
- _added
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement