What is it, that you are looking for, that the engine stays running because this already exists.
If you want the hold F to turn off the engine add this to the client.lua
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = GetPlayerPed(-1)
if DoesEntityExist(ped) and IsPedInAnyVehicle(ped, false) and IsControlPressed(2, 75) and not IsEntityDead(ped) and not IsPauseMenuActive() then
local engineWasRunning = GetIsVehicleEngineRunning(GetVehiclePedIsIn(ped, true))
Citizen.Wait(1000)
if DoesEntityExist(ped) and not IsPedInAnyVehicle(ped, false) and not IsEntityDead(ped) and not IsPauseMenuActive() then
local veh = GetVehiclePedIsIn(ped, true)
if (engineWasRunning) then
SetVehicleEngineOn(veh, true, true, true)
end
end
end
end
end)
local pressed = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local timer = 0
local vehicle = GetVehiclePedIsIn(player, false)
while IsControlPressed(0, 75) do
Citizen.Wait(0)
timer = timer + 3
if IsVehicleEngineOn(vehicle) then
SetVehicleEngineOn(vehicle, false, false, true)
SetVehicleUndriveable(vehicle, true)
end
if timer > 60 then
pressed = true
break
end
end
while not IsControlJustReleased(0, 75) do
Citizen.Wait(0)
end
pressed = false
end
end)
Credit to Vespura for that code ^^^
my bad i not was search…thanks ^^
No worries.
(20 Characters)
1 Like
and for radio to stay open ?