[HELP] (Solved) How do I disable fuel and oil leaking from vehicles?

Hi everyone,

I’ve been working on setting up a private freeroam server for me and my friends, with a focus on PvP. While everything else is running smoothly thus far, I’ve run into a big problem due to one specific issue: fuel and oil leaking from vehicles.

It’s extremely annoying, because this mechanic hinders the PvP gameplay a lot. Heavily armored vehicles like the Nightshark and Insurgent Custom, are meant to last longer in PvP, but once they start leaking fuel and oil, the vehicles get destroyed faster, especially when a lot of explosions happen and the fuel and oil start catching fire. The mechanic is disabled in GTAO but seems to be active by default in FiveM.

I’ve tried absolutely everything I could think of, including searching through the Cfx.re native references and tweaking various settings, but nothing has worked so far.

Is there any way to globally disable both fuel and oil leaking from vehicles in a FiveM server? I would like it completely gone for all vehicles, armoured or not, at all times.

If anyone has managed to fix it or has a fix ready, I’d really appreciate if I could get it explained. Thanks in advance!

Have you tried these?

I did try these, though the vehicle still leaks fuel and oil.

What I currently have is a script that instantly heals the engine and tank when inside to the fullest, but it makes the vehicle godmode for me sometimes, so yeah that’s only a temp solution until I really find out how to implement native functions properly.

See the native here as well, there’s reference to a vehicle starting to seep out gas if its engine health is under a specific value - worth running a loop to reset it every X seconds? May be the other cause you’re missing, as the natives posted originally are literally undocumented besides their existence lol

Could also give this a try as well same method as what @_4iY said.

I should’ve been more clear here, but I have a script that does exactly this, if the vehicle’s petrol tank and engine take damage it instantly gets healed;

This is my script I tried making with my VERY limited Lua knowledge, never written stuff in Lua before starting a FiveM server 2 weeks ago, so apologies if this looks messy or something:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local playerPed = PlayerPedId()
        local vehicle = GetVehiclePedIsIn(playerPed, false)
        if vehicle and DoesEntityExist(vehicle) then
            -- Reset health values if damage occurs
            if GetVehiclePetrolTankHealth(vehicle) < 1000.0 then
                SetVehiclePetrolTankHealth(vehicle, 1000.0)
            end
            if GetVehicleEngineHealth(vehicle) < 1000.0 then
                SetVehicleEngineHealth(vehicle, 1000.0)
            end
        end
    end
end)

But yeah as I said, idk if I’m doing something wrong here but it makes the vehicle completely godmode (in case for non armoured vehicles, however this seemed to ONLY happen if my non armoured vehicle gets attacked by another player, if I blow myself up with a sticky for example the vehicle does explode.)

(Edit, tested this while writing the reply: also realized this happens on armoured vehicles too, I can destroy my own vehicle, but other players cannot)

Uh, if that’s your goal, why not just make the vehicle unable to take damage in the first place? What your script does is basically making it godmode (by resetting its HP to maximum), you should use 650 as the cutoff point like the natives say.
EDIT: The retval is indicated as a number, verify that you’re using the right format as you’re using a float value. Printing the return of GetVehicleEngineHealth will show you what format it’s in.

Well yeah, that’s not my goal, I do not want the vehicle to be in godmode.

So I’m gonna try putting it to 650 now, I’ll let you know if it works. Thanks for the help so far!

It works as a temp solution for now, thanks!

Though is it really not possible to disable these native functions? I found this post from almost 3 years ago stating they had a similar problem regarding the fuel tanks: Disabling Fuel Tank Leaking and Aircraft "Borrowed Time"

Though sadly no matter what I do, using the entire vehicle pool, only one vehicle, heck even modifying my script where I disabled the T 250 D’s control surfaces breaking off (which works) to add this functionality, but nothing worked so far sadly. I’m honestly lost at this point, especially with my limited knowledge.

This maybe? SetDisableVehiclePetrolTankDamage - FiveM Natives @ Cfx.re Docs
Or this? SetVehicleCanLeakPetrol - FiveM Natives @ Cfx.re Docs

SetDisableVehiclePetrolTankDamage works! Thanks for the help! :slight_smile:

1 Like