heres my version of autopilot drives to your current waypoint.
Press Space to emergency brake + regain control at any time
CTRL + shift to toggle normally
your car will act like AI if you dont shutoff autopilot when you hit your waypoint, never fixed this issue…
also you can adjust your speed while in autopilot by pressing W or S
function translatespeed(float)
local speed = float + 11
return speed
end
autopilotenabled = false
Citizen.CreateThread(function()
while true do
local waypointBlip = GetFirstBlipInfoId(8) -- 8 = Waypoint ID
local x,y,z = table.unpack(Citizen.InvokeNative(0xFA7C7F0AADF25D09, waypointBlip, Citizen.ResultAsVector()))
local px,py,pz = table.unpack(GetEntityCoords(PlayerPedId()))
local distbetween = Vdist(x,y,z,px,py,pz)
if IsControlPressed(1,36) then
if IsControlJustPressed(1,21) then
if GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1894894188 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -429774847 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1622444098 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == 884483972 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == 569305213 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1285460620 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -1529242755 or GetEntityModel(GetVehiclePedIsUsing(PlayerPedId())) == -429774847 then
autopilotenabled = not autopilotenabled
if autopilotenabled then
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~g~Engaged")
DrawNotification(false, true)
if(not IsWaypointActive())then
SetNotificationTextEntry("STRING")
AddTextComponentString("~r~ERROR:~w~ No Destination Set.")
DrawNotification(true, true)
autopilotenabled = false
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~r~Deactivated")
DrawNotification(true, true)
TaskPause(PlayerPedId(), 10)
else
defaultspeed = 20.0 --1 = 3 MPH 5 = 11 MPH
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0) --262579
end
else
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~r~Deactivated")
DrawNotification(false, true)
TaskPause(PlayerPedId(), 10)
end
else
SetNotificationTextEntry("STRING")
AddTextComponentString("This Vehicle is not equipped with ~y~Autopilot~w~!")
DrawNotification(false, true)
end
end
end
if autopilotenabled then
if IsControlJustPressed(0, 71) and GetLastInputMethod( 0 ) then
defaultspeed = defaultspeed + 1.0
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0)
end
if IsControlJustPressed(0,72) and GetLastInputMethod( 0 ) then
defaultspeed = defaultspeed - 1.0
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0)
end
if IsControlJustPressed(0,76) and GetLastInputMethod( 0 ) then
defaultspeed = 0.0
TaskVehicleDriveToCoordLongrange(PlayerPedId(),GetVehiclePedIsUsing(PlayerPedId()), x,y,z, defaultspeed, 262579, 1.0)
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~[Autopilot]~r~ Emergency Stop Engaged")
DrawNotification(true, true)
SetNotificationTextEntry("STRING")
AddTextComponentString("~y~Autopilot ~r~Deactivated")
DrawNotification(false, true)
TaskPause(PlayerPedId(), 10)
autopilotenabled = false
end
end
Citizen.Wait(0)
end
end)