Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- span class="re5"> params [["_container",0],["_unit",player]];
- if(_container < 3 || _container > 5) exitWith {[]};
- _items = (((getUnitLoadout _unit) select _container) select 1);
- _newItems = [];
- _exit = false;
- _count = count _items;
- while {_count != (count _newItems)} do {
- _i = _items findIf {count _x == 2 && (_x select 0) isEqualType []}; // Check if its a weapon, if so do special things
- if(_i != -1) then { // is Weapon
- _wepArray = _items select _i;
- _newI = _newItems findIf {_x select 0 isEqualTo (_wepArray select 0)}; // check if the same weapon array already exist in _newItems array
- if(_newI != -1) then { // getUnitLoadout doesn't return the weapons in right order always. Because of this we need to check if a stacked weapon exist in the array
- _newItems set [_newI,[((_wepArray) select 0),(((_newItems select _i) select 1) + (_wepArray select 1))]]; // Add more weapon(s) to array (works in setUnitLoadout)
- } else {
- _newItems pushBack _wepArray;
- };
- _items deleteAt _i;
- } else {
- _i = _items findIf {count _x == 2 && (_x select 1) isEqualType 0};
- if(_i != -1) then { // is Item
- _newItems pushBack (_items select _i);
- _items deleteAt _i;
- } else {
- _i = _items findIf {count _x == 3};
- if(_i != -1) then { // is Magazine
- _newItems pushBack (_items select _i);
- _items deleteAt _i;
- } else { // Should be backpack but lets still make sure!
- _i = _items findIf {count _x == 2 && (_x select 1) isEqualType true};
- if(_i != -1) then { // is Backpack
- _newItems pushBack (_items select _i);
- _items deleteAt _i;
- } else {
- _exit = true; // R.I.P
- };
- };
- };
- };
- if(_exit) exitWith {diag_log format ["ERROR: ITEM'S INVALID: %1 --- _newItems: %2",_items,_newItems]};
- };
- _newItems;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement