This is a cruisecontrol resource i have had for quite some time but did not bother to release. However a couple of friends of mine asked for it so i thought why not just release it on the forums.
How it works:
When driving click the Y button (default on nordic keyboards) and the cruisespeed will be set.
If you want to increase the speed just speed up alittle on W and the cruisecontroller will reset the speed to the new current one.
If you want to turn it off push the Y button but without touching any other button at the same time, or it will not work.
You can also turn it off by breaking below around the 40 km/h.
This text: âTĂNDTâ and âSLUKKETâ makes no sense so you could change it to something like:
NotificationMessage("CruiseControl: ~g~ ON ~w~ - ~b~ " .. cruiseMph .."mph")
NotificationMessage("CruiseControl: ~r~ OFF")
This will display:
âCruiseControl: ON - XXmphâ
&
âCruiseControl: OFFâ
Get rid of notifications all together for integration with CarHud
If you want to get rid of all the notifications because youâre integrating this plugin with âCarhudâ then replace your cl_cruisecontrol.lua with this:
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(1, 56) then
TriggerEvent('pv:setCruiseSpeed')
end
end
end)
local cruise = 0
AddEventHandler('pv:setCruiseSpeed', function()
if cruise == 0 and IsPedInAnyVehicle(GetPlayerPed(-1), false) then
if GetEntitySpeedVector(GetVehiclePedIsIn(GetPlayerPed(-1), false), true)['y'] > 0 then
cruise = GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))
local cruiseKm = math.floor(cruise * 3.6 + 0.5)
local cruiseMph = math.floor(cruise * 2.23694 + 0.5)
Citizen.CreateThread(function()
while cruise > 0 and GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), -1) == GetPlayerPed(-1) do
local cruiseVeh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
if IsVehicleOnAllWheels(cruiseVeh) and GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false)) > (cruise - 2.0) then
SetVehicleForwardSpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false), cruise)
else
cruise = 0
break
end
if IsControlPressed(1, 8) then
cruise = 0
end
if IsControlPressed(1, 32) then
cruise = 0
TriggerEvent('pv:setNewSpeed')
end
if cruise > 44 then
cruise = 0
break
end
Wait(200)
end
cruise = 0
end)
else
cruise = 0
end
else
if cruise > 0 then
end
cruise = 0
end
end)
AddEventHandler('pv:setNewSpeed', function()
Citizen.CreateThread(function()
while IsControlPressed(1, 32) do
Wait(1)
end
TriggerEvent('pv:setCruiseSpeed')
end)
end)
function NotificationMessage(message)
SetNotificationTextEntry("STRING")
AddTextComponentString(message)
DrawNotification(0,1)
end
Boats are exploited in this script in terms if you hit the cruise control button over and over again it will make the boat fly. I offer my fix below.
Even though this script is old, it still works perfectly and is still very relevant today, and with a slight modification to it to disable it if the player is in a boat, its perfect.
Replace with the following code from line 13
Line 13 code:
if cruise == 0 and IsPedInAnyVehicle(GetPlayerPed(-1), false) then
With:
if IsPedInAnyBoat(GetPlayerPed(-1), false) then
cruise = 0
NotificationMessage(âCruiseControl: ~r~ BOATS CANâT!â)
elseif cruise == 0 and IsPedInAnyVehicle(GetPlayerPed(-1), false) then