From 10607cc2a6f571c5421476a7a85578c5df42ac6f Mon Sep 17 00:00:00 2001 From: sethduda Date: Sun, 20 Mar 2016 22:41:42 -0400 Subject: [PATCH] Removing ability to tow locked vehicles and in exile safe zones --- .../functions/fn_advancedTowingInit.sqf | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/addons/SA_AdvancedTowing/functions/fn_advancedTowingInit.sqf b/addons/SA_AdvancedTowing/functions/fn_advancedTowingInit.sqf index a45f55d..24872ae 100644 --- a/addons/SA_AdvancedTowing/functions/fn_advancedTowingInit.sqf +++ b/addons/SA_AdvancedTowing/functions/fn_advancedTowingInit.sqf @@ -338,12 +338,8 @@ SA_Attach_Tow_Ropes_Action = { private ["_vehicle","_towVehicle"]; _vehicle = cursorTarget; _towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull]; - if(!isNull _towVehicle && !isNull _vehicle) then { - if([_towVehicle,_vehicle] call SA_Is_Supported_Cargo && vehicle player == player && player distance _vehicle < 10 && _towVehicle != _vehicle) then { - [_vehicle,player] call SA_Attach_Tow_Ropes; - } else { - false; - }; + if([_vehicle] call SA_Can_Attach_Tow_Ropes) then { + [_vehicle,player] call SA_Attach_Tow_Ropes; } else { false; }; @@ -352,14 +348,29 @@ SA_Attach_Tow_Ropes_Action = { SA_Attach_Tow_Ropes_Action_Check = { private ["_vehicle","_towVehicle","_isCargoBeingTowed","_isCargoTowingCargo","_isChainingEnabled","_isTowVehicleBeingTowed","_isTowVehicleTowingCargo"]; _vehicle = cursorTarget; + [_vehicle] call SA_Can_Attach_Tow_Ropes; +}; + +SA_Can_Attach_Tow_Ropes = { + params ["_cargo"]; + private ["_towVehicle","_isCargoBeingTowed","_isCargoTowingCargo","_isChainingEnabled","_isTowVehicleBeingTowed","_isTowVehicleTowingCargo","_canBeTowed"]; _towVehicle = player getVariable ["SA_Tow_Ropes_Vehicle", objNull]; - if(!isNull _towVehicle && !isNull _vehicle) then { + if(!isNull _towVehicle && !isNull _cargo) then { _isChainingEnabled = missionNamespace getVariable ["SA_TOW_CHAINS_ENABLED",false]; - _isCargoBeingTowed = not isNull (_vehicle getVariable ["SA_TOWING_VEHICLE",objNull]); - _isCargoTowingCargo = not isNull (_vehicle getVariable ["SA_TOWING_CARGO",objNull]); + _isCargoBeingTowed = not isNull (_cargo getVariable ["SA_TOWING_VEHICLE",objNull]); + _isCargoTowingCargo = not isNull (_cargo getVariable ["SA_TOWING_CARGO",objNull]); _isTowVehicleBeingTowed = not isNull (_towVehicle getVariable ["SA_TOWING_VEHICLE",objNull]); _isTowVehicleTowingCargo = not isNull (_towVehicle getVariable ["SA_TOWING_CARGO",objNull]); - [_towVehicle,_vehicle] call SA_Is_Supported_Cargo && vehicle player == player && player distance _vehicle < 10 && _towVehicle != _vehicle && !_isTowVehicleTowingCargo && !_isCargoBeingTowed && ((!_isTowVehicleBeingTowed && !_isCargoTowingCargo) || _isChainingEnabled); + _canBeTowed = [_towVehicle,_cargo] call SA_Is_Supported_Cargo && vehicle player == player && player distance _cargo < 10 && _towVehicle != _cargo && !_isTowVehicleTowingCargo && !_isCargoBeingTowed && ((!_isTowVehicleBeingTowed && !_isCargoTowingCargo) || _isChainingEnabled); + if(!missionNamespace getVariable ["SA_TOW_LOCKED_VEHICLES_ENABLED",false]) then { + _canBeTowed = _canBeTowed && locked _cargo <= 1; + }; + if(!missionNamespace getVariable ["SA_TOW_IN_EXILE_SAFEZONE_ENABLED",false]) then { + if(!isNil "ExilePlayerInSafezone") then { + _canBeTowed = _canBeTowed && ExilePlayerInSafezone; + }; + }; + _canBeTowed; } else { false; };