Hey guys, I'm tickering with a towing script and I'm having issues...
I have it setup so cars can tow other cars but I ran into a problem where the script will try to attach the players vehicle to itself and ignore any other vehicles. As in, the nearest "car" the script picks up is the "car" the player is in. Is there a way to make the script ignore the players car?
Script
_carrier = _this select 0;
_pilot = _this select 1;
_action = _this select 2;
_nearest = nearestObject [(vehicle player), "Car"];
if ((typeOf _nearest) == "") exitWith { _carrier vehicleChat "No vehicles nearby" };
_carrier removeAction _action;
_carrier setVariable ["cancelledAttach", false];
_cancelAction = _carrier addAction ["Cancel Tow", "cancelAttach2.sqf", [], 1, false, true, "", "driver _target == player"];
_carrier vehicleChat format ["Ready to attach vehicle --%1--", typeOf _nearest];
waitUntil { ( (_carrier distance _nearest) < 5 ) || _carrier getVariable "cancelledAttach" };
if (_carrier getVariable "cancelledAttach") exitWith { _carrier vehicleChat "Cancelled Vehicle Attach" };
_carrier vehicleChat format ["%1 now attached", typeOf _nearest];
_carrier setVariable ["attached", true];
_carrier removeAction _cancelAction;
_carrier addAction ["Detach Vehicle", "detachVehicle2.sqf", _nearest, 1, false, true, "", "driver _target == player"];
while { _carrier getVariable "attached" } do {
_nearest Attachto [_carrier,[0,-4,-1]];
sleep 0.25;
};
[_carrier, _nearest] execVM "dropVehicle2.sqf";
If anyone has any ideas, I would appreciate it.