@@ -39,12 +39,12 @@ _this spawn {
3939
4040 if (_iswarehouse ) then {
4141 {
42- _cls = _x select 0 ;
43- _d = warehouse getVariable [( _x select 0 ) ,[_cls ,0 ]];
44- if (typename _d == " ARRAY " ) then {
45- _num = _x select 1 ;
42+ _x params [ " _cls " , " _num " ] ;
43+ _d = warehouse getVariable [format [ " item_%1 " , _cls ] ,[_cls ,0 ]];
44+ if (_d isEqualType [] ) then {
45+ _d params [ " _wCls " ,[ " _in " , 0 ]] ;
4646 _in = _d select 1 ;
47- warehouse setVariable[_cls ,[_cls ,_in + _num ],true ];
47+ warehouse setVariable[format [ " item_%1 " , _cls ] ,[_cls ,_in + _num ],true ];
4848 };
4949 }foreach (_target call OT_fnc_unitStock );
5050 clearMagazineCargoGlobal _target ;
@@ -56,51 +56,48 @@ _this spawn {
5656 _x params [[" _cls" ," " ], [" _max" ,0 ]];
5757 private _count = 0 ;
5858 private _full = false ;
59- while {_count < _max } do {
60- if (! (_veh isKindOf " Truck_F" || _veh isKindOf " ReammoBox_F" ) && ! (_veh canAdd _cls )) exitWith {
61- _full = true ;
59+
60+ if ((_veh isKindOf " Truck_F" || _veh isKindOf " ReammoBox_F" )) then {
61+ _count = _max ;
62+ } else {
63+ while {_count < _max } do {
64+ if (! (_veh canAdd [_cls ,_count + 1 ])) exitWith {_full = true ;};
65+ _count = _count + 1 ;
6266 };
63- _count = _count + 1 ;
64- [_veh , _cls ] call {
65- params [" _veh" , " _cls" ];
67+ };
68+
69+ if (_count > 0 ) then {
70+ [_veh , _target , _cls , _count ] call {
71+ params [" _veh" , " _target" ," _cls" , " _count" ];
6672 if (_cls isKindOf " Bag_Base" ) exitWith {
6773 _cls = _cls call BIS_fnc_basicBackpack ;
68- _veh addBackpackCargoGlobal [_cls ,1 ];
74+ _veh addBackpackCargoGlobal [_cls ,_count ];
75+ [_target , _cls , _count ] call CBA_fnc_removeBackpackCargo ;
6976 };
7077 if (_cls isKindOf [" Rifle" ,configFile >> " CfgWeapons" ]) exitWith {
71- _veh addWeaponCargoGlobal [_cls ,1 ];
78+ _veh addWeaponCargoGlobal [_cls ,_count ];
79+ [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
7280 };
7381 if (_cls isKindOf [" Launcher" ,configFile >> " CfgWeapons" ]) exitWith {
74- _veh addWeaponCargoGlobal [_cls ,1 ];
82+ _veh addWeaponCargoGlobal [_cls ,_count ];
83+ [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
7584 };
7685 if (_cls isKindOf [" Pistol" ,configFile >> " CfgWeapons" ]) exitWith {
77- _veh addWeaponCargoGlobal [_cls ,1 ];
86+ _veh addWeaponCargoGlobal [_cls ,_count ];
87+ [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
7888 };
7989 if (_cls isKindOf [" Binocular" ,configFile >> " CfgWeapons" ]) exitWith {
80- _veh addWeaponCargoGlobal [_cls ,1 ];
90+ _veh addWeaponCargoGlobal [_cls ,_count ];
91+ [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
8192 };
8293 if (_cls isKindOf [" CA_Magazine" ,configFile >> " CfgMagazines" ]) exitWith {
83- _veh addMagazineCargoGlobal [_cls ,1 ];
94+ _veh addMagazineCargoGlobal [_cls ,_count ];
95+ [_target , _cls , _count ] call CBA_fnc_removeMagazineCargo ;
96+ };
97+ _veh addItemCargoGlobal [_cls ,_count ];
98+ if ! ([_target , _cls , _count ] call CBA_fnc_removeItemCargo ) then {
99+ [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
84100 };
85- _veh addItemCargoGlobal [_cls ,1 ];
86- };
87- };
88- [_target , _cls , _count ] call {
89- params [" _target" , " _cls" , " _count" ];
90- if (_cls isKindOf " Bag_Base" ) exitWith {
91- [_target , _cls , _count ] call CBA_fnc_removeBackpackCargo ;
92- };
93- if (_cls isKindOf [" Rifle" ,configFile >> " CfgWeapons" ]) exitWith {
94- [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
95- };
96- if (_cls isKindOf [" Launcher" ,configFile >> " CfgWeapons" ]) exitWith {
97- [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
98- };
99- if (_cls isKindOf [" CA_Magazine" ,configFile >> " CfgMagazines" ]) exitWith {
100- [_target , _cls , _count ] call CBA_fnc_removeMagazineCargo ;
101- };
102- if ! ([_target , _cls , _count ] call CBA_fnc_removeItemCargo ) then {
103- [_target , _cls , _count ] call CBA_fnc_removeWeaponCargo ;
104101 };
105102 };
106103 if (_full ) exitWith {hint " The vehicle is full, use a truck or ammobox for more storage" };
0 commit comments