So I am trying to push a button and make the car not be able to move but still be able to rev. I have tried a couple things but have had various issues:
SetVehicleClutch(pedVehicle, 0.0) --doesn’t work, clutch setting doesn’t stick in game
SetVehicleHighGear(pedVehicle, 0) --unable to get into neutral
FreezeEntityPosition(pedVehicle, true) --freezes car but doesn’t rev
SetVehicleHandbrake(pedVehicle, true) – Works but cannot disable handbrake later
Any other ideas or functions that will let me do this?
SetVehicleHandbrake(pedVehicle, true)must work because i have used it a few times, just put false instead of true , also you can use SetVehicleBrake(veh,bool)
If not works make sure the vehicle is properly targeted (check if pedVehicle is not null)
In you’re loop to register the button pressed you need a bool to toggle on and off the effect will look something like this:
(This is untested and messy but should help you out)
local IsActive = false
Citizen.CreateThread( function()
while true do
Citizen.Wait(0)
if IsControlJustReleased(0, KEYTOPRESS) and IsPedInAnyVehicle(PlayerPedId(), false) and not IsActive then
IsActive = true
SetVehicleHandbrake(pedVehicle, true)
elseif IsControlJustReleased(0, KEYTOPRESS) and IsPedInAnyVehicle(PlayerPedId(), false) and IsActive then
IsActive = false
SetVehicleHandbrake(pedVehicle, false)
elseif not IsPedInAnyVehicle(PlayerPedId(), false) and IsActive then
IsActive = false
end
end
end)
Thank you! I can use this as a template for what I am trying to do bc I am having some difficulties with the same button doing two things at the same time.