diff --git a/addons/cargo/functions/fnc_addCargoItem.sqf b/addons/cargo/functions/fnc_addCargoItem.sqf index 38ccdc0dd94..de262bdcfb5 100644 --- a/addons/cargo/functions/fnc_addCargoItem.sqf +++ b/addons/cargo/functions/fnc_addCargoItem.sqf @@ -7,9 +7,10 @@ * 0: Item to be loaded or * 1: Holder object (vehicle) * 2: Amount (default: 1) + * 3: Ignore interaction distance and stability checks (default: false) * * Return Value: - * None + * Objects loaded * * Example: * ["ACE_Wheel", cursorObject] call ace_cargo_fnc_addCargoItem @@ -17,21 +18,29 @@ * Public: No */ -params ["_item", "_vehicle", ["_amount", 1]]; -TRACE_3("params",_item,_vehicle,_amount); +params ["_item", "_vehicle", ["_amount", 1], ["_ignoreInteraction", false]]; +TRACE_4("params",_item,_vehicle,_amount,_ignoreInteraction); + +private _loaded = 0; // Get config sensitive case name if (_item isEqualType "") then { _item = _item call EFUNC(common,getConfigName); for "_i" from 1 to _amount do { - [_item, _vehicle] call FUNC(loadItem); + if !([_item, _vehicle, _ignoreInteraction] call FUNC(loadItem)) exitWith {}; + + _loaded = _loaded + 1; }; } else { - [_item, _vehicle] call FUNC(loadItem); + _loaded = parseNumber ([_item, _vehicle, _ignoreInteraction] call FUNC(loadItem)); _item = typeOf _item; }; +TRACE_1("loaded",_loaded); + // Invoke listenable event -["ace_cargoAdded", [_item, _vehicle, _amount]] call CBA_fnc_globalEvent; +["ace_cargoAdded", [_item, _vehicle, _loaded]] call CBA_fnc_globalEvent; + +_loaded // return diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index af80761fe0c..25cebe5b130 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -52,14 +52,21 @@ if (isServer) then { private _cargoClassname = ""; private _cargoCount = 0; + private _loaded = 0; { _cargoClassname = getText (_x >> "type"); _cargoCount = getNumber (_x >> "amount"); - TRACE_3("adding ACE_Cargo",configName _x,_cargoClassname,_cargoCount); + TRACE_3("adding ace_cargo",configName _x,_cargoClassname,_cargoCount); - ["ace_addCargo", [_cargoClassname, _vehicle, _cargoCount]] call CBA_fnc_localEvent; + // Ignore stability check (distance check is also ignored with this, but it's ignored by default if item is a string) + _loaded = [_cargoClassname, _vehicle, _cargoCount, true] call FUNC(addCargoItem); + + // Let loop continue until the end, so that it prints everything into the rpt (there might be smaller items that could still fit in cargo) + if (_loaded != _cargoCount) then { + WARNING_5("%1 (%2) could not fit %3 %4 inside its cargo, only %5 were loaded.",_vehicle,_type,_cargoCount,_cargoClassname,_loaded); + }; } forEach ("true" configClasses (_config >> QUOTE(ADDON) >> "cargo")); };