I am trying to create a script that sets the vehicle engine on/off according to the vehicles current engineStatus
but when the player hits the keybind ( LCTRL + W
) it doesn’t turn the engine on. I know the keybind is working fine because it displays the proper You're not in a vehicle.
or You are in a vehicle.
message.
-- if player hits 'LCTRL + W' - toggle engine
if IsControlPressed(0, Keys['LEFTCTRL']) and IsControlJustPressed(0, Keys['W']) then
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
local engineStatus = GetIsVehicleEngineRunning(vehicle)
if vehicle == 0 then
ShowNotification("~r~You're not in a vehicle.")
else
ShowNotification("~b~You are in a vehicle.")
if not engineStatus then
SetVehicleEngineOn( vehicle, true, true )
else
SetVehicleEngineOn( vehicle, false, true )
end
end
end