Skip to content

Instantly share code, notes, and snippets.

@userMacieG
Last active March 22, 2024 12:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save userMacieG/499165be97fb6c091986acade3fec0f8 to your computer and use it in GitHub Desktop.
Save userMacieG/499165be97fb6c091986acade3fec0f8 to your computer and use it in GitHub Desktop.
Turn engine on and off via key (ox_lib)
lib.onCache('ped', function(value)
SetPedConfigFlag(value, 241, true) -- PED_FLAG_DISABLE_STOPPING_VEHICLE_ENGINE
SetPedConfigFlag(value, 429, true) -- PED_FLAG_DISABLE_STARTING_VEHICLE_ENGINE
end)
lib.addKeybind({
name = 'engine',
description = 'Engine',
defaultKey = 'Y',
onPressed = function(self)
if not cache.vehicle then
-- Player is not in vehicle
return
end
if not cache.seat then
-- Player is not a driver
return
end
if GetVehicleClass(cache.vehicle) == 13 then
-- Vehicle is a bike
return
end
SetVehicleEngineOn(cache.vehicle, not GetIsVehicleEngineRunning(cache.vehicle), false, true)
end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment