diff --git a/addons/cargo/functions/fnc_canLoad.sqf b/addons/cargo/functions/fnc_canLoad.sqf index f576ea3e79..e0fd172eef 100644 --- a/addons/cargo/functions/fnc_canLoad.sqf +++ b/addons/cargo/functions/fnc_canLoad.sqf @@ -21,7 +21,7 @@ TRACE_2("params",_player,_object); if (!([_player, _object, []] call EFUNC(common,canInteractWith))) exitWith {false}; -private _nearestVehicle = [_player] call FUNC(findNearestVehicle); +private _nearestVehicle = [_player, _object] call FUNC(findNearestVehicle); if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then { { diff --git a/addons/cargo/functions/fnc_canLoadItemIn.sqf b/addons/cargo/functions/fnc_canLoadItemIn.sqf index e2bb1ecc4d..77a230108c 100644 --- a/addons/cargo/functions/fnc_canLoadItemIn.sqf +++ b/addons/cargo/functions/fnc_canLoadItemIn.sqf @@ -20,6 +20,11 @@ params [["_item", "", [objNull,""]], "_vehicle"]; if (speed _vehicle > 1 || {((getPos _vehicle) select 2) > 3}) exitWith {TRACE_1("vehicle not stable",_vehicle); false}; +if (_item isEqualType objNull && {{alive _x && {getText (configFile >> "CfgVehicles" >> typeOf _x >> "simulation") != "UAVPilot"}} count crew _item > 0}) exitWith { + TRACE_1("item is occupied",_item); + false +}; + private _itemSize = [_item] call FUNC(getSizeItem); private _validItem = false; if (_item isEqualType "") then { diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index 6d5b7ce1a8..7981782255 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -1,35 +1,41 @@ /* * Author: Glowbal - * Get nearest vehicle from unit, priority: Car-Air-Tank-Ship. + * Get nearest vehicle from unit that is not excluded, priority: Car-Air-Tank-Ship. * * Arguments: * 0: Unit + * 1: Object to exclude * * Return Value: * Vehicle in Distance * * Example: - * [unit] call ace_cargo_fnc_findNearestVehicle + * [unit, object] call ace_cargo_fnc_findNearestVehicle * * Public: No */ #include "script_component.hpp" -params ["_unit"]; +params ["_unit","_object"]; -private _loadCar = nearestObject [_unit, "car"]; -if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitWith {_loadCar}; +private _loadCar = nearestObjects [_unit, ["car"], MAX_LOAD_DISTANCE]; +_loadCar deleteAt (_loadCar find _object); +if !(_loadCar isEqualTo []) exitWith {_loadCar select 0}; -private _loadHelicopter = nearestObject [_unit, "air"]; -if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitWith {_loadHelicopter}; +private _loadHelicopter = nearestObjects [_unit, ["air"], MAX_LOAD_DISTANCE]; +_loadHelicopter deleteAt (_loadHelicopter find _object); +if !(_loadHelicopter isEqualTo []) exitWith {_loadHelicopter select 0}; -private _loadTank = nearestObject [_unit, "tank"]; -if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitWith {_loadTank}; +private _loadTank = nearestObjects [_unit, ["tank"], MAX_LOAD_DISTANCE]; +_loadTank deleteAt (_loadTank find _object); +if !(_loadTank isEqualTo []) exitWith {_loadTank select 0}; -private _loadShip = nearestObject [_unit, "ship"]; -if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitWith {_loadShip}; +private _loadShip = nearestObjects [_unit, ["ship"], MAX_LOAD_DISTANCE]; +_loadShip deleteAt (_loadShip find _object);; +if !(_loadShip isEqualTo []) exitWith {_loadShip select 0}; -private _loadContainer = nearestObject [_unit,"Cargo_base_F"]; -if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitWith {_loadContainer}; +private _loadContainer = nearestObjects [_unit, ["Cargo_base_F"], MAX_LOAD_DISTANCE]; +_loadContainer deleteAt (_loadContainer find _object); +if !(_loadContainer isEqualTo []) exitWith {_loadContainer select 0}; objNull diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index 466471c375..8af411bddd 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -19,7 +19,7 @@ params ["_player", "_object"]; TRACE_2("params",_player,_object); -private _vehicle = [_player] call FUNC(findNearestVehicle); +private _vehicle = [_player, _object] call FUNC(findNearestVehicle); if ((isNull _vehicle) || {_vehicle isKindOf "Cargo_Base_F"}) then { {