Last active
March 22, 2024 12:19
-
-
Save userMacieG/499165be97fb6c091986acade3fec0f8 to your computer and use it in GitHub Desktop.
Turn engine on and off via key (ox_lib)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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