Last active
November 3, 2016 17:26
-
-
Save SamJUK/ff01f3b674f70a2bec14fc456b8b99e1 to your computer and use it in GitHub Desktop.
Updated A3L__TowTruck's Tow script | Addd ATM safezone check, Alive player check, moving chekcs etc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
File: Tow.sqf | |
Author: Caiden | |
Description: | |
Main handler for attempting to tow/untow a vehicle | |
*/ | |
_veh = _this; | |
_isTowing = _veh getVariable "isTowing"; | |
if (!isNil "_isTowing") then { | |
_myveh = vehicle player; | |
_myveh allowDamage false; | |
detach ((vehicle player) getVariable "isTowing"); | |
// Move 2M back | |
_pos = ((vehicle player) getVariable "isTowing") modelToWorld [0,-3,-3]; | |
_pos = [_pos select 0,_pos select 1,1]; | |
((vehicle player) getVariable "isTowing") setpos _pos; | |
((vehicle player) getVariable "isTowing") setVariable ["isBeingTowed",nil,true]; | |
(vehicle player) setVariable ["isTowing",nil,true]; | |
sleep 3; | |
_myveh allowDamage true; | |
} else { | |
_near = nearestObjects [(vehicle player), ["Car","Truck","Motorcycle"], 9]; | |
_near = _near - [vehicle player]; | |
//Check if the tow truck is in motion | |
if (speed _veh > 3) exitWith { | |
["You are driving too fast!",20,"red"] call A3L_Fnc_Msg; | |
}; | |
if (count _near < 1) exitwith { | |
["No towable vehicle nearby",20,"red"] call A3L_Fnc_Msg; | |
}; | |
if ((vehicle player) animationPhase "Tow" > 0.1) exitwith { | |
["Towbar is not lowered",20,"red"] call A3L_Fnc_Msg; | |
}; | |
_nearest = _near select 0; | |
//if (locked _nearest > 1) exitwith { | |
// ["This vehicle is locked and cannot be towed",20,"red"] call A3L_Fnc_Msg; | |
//}; | |
//Check for alive players inside | |
if ({alive _x} count crew _nearest > 0)exitWith { | |
["The vehicle is not empty",20,"red"] call A3L_Fnc_Msg; | |
}; | |
/*//Check is players or dead bodies are in the car | |
if (count crew _nearest > 0)exitWith { | |
["The vehicle is not empty",20,"red"] call A3L_Fnc_Msg; | |
};*/ | |
//Check if its moving | |
if (speed _nearest > 1)exitWith { | |
["The vehicle is in motion",20,"red"] call A3L_Fnc_Msg; | |
}; | |
//Check if within 10m of an ATM | Normal ATM, ATM with roof | XCAM Varients | Black & yellow ATM | |
if (count nearestObjects [getPos player, ["Land_Atm_01_F","Land_Atm_02_F","xcam_Atm_01_F","xcam_Atm_02_F","Land_Mattaust_ATM"], 15] > 0) exitWith { | |
["You are too close to an ATM",20,"red"] call A3L_Fnc_Msg; | |
}; | |
_isTowed = _nearest getVariable "isTowing"; | |
_isBeingTowed = _nearest getVariable "isBeingTowed"; | |
if ((!isNil "_isTowed") OR (!isNil "_isBeingTowed")) exitwith { | |
["Vehicle is already being towed or is towing another vehicle",20,"red"] call A3L_Fnc_Msg; | |
}; | |
// Get attachpoint | |
_attachpoint = []; | |
_lookfor = typeof _nearest; | |
{ | |
if ((_x select 0) == _lookfor) then { | |
_attachpoint = _x select 1; | |
}; | |
} foreach A3L_Fnc_TowArray; | |
if (count _attachpoint == 0) then { | |
_nearest attachTo [(vehicle player), [0, -7, -1.5] ]; | |
} else { | |
_nearest attachto [(vehicle player),_attachpoint]; | |
}; | |
[[_nearest],"A3L_Fnc_TowtruckVector", true, false] call BIS_fnc_MP; | |
(vehicle player) setVariable ["isTowing",_nearest,true]; | |
_nearest setVariable ["isBeingTowed",true,true]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment