Garages: saving fuel level and mix

A tank can hold a blend — petrol topped up with diesel, a mixed jerry can poured in. The LegacyFuel decor _FUEL_LEVEL only keeps the level, so a garage that saves just that brings every car back with clean fuel of its engine's own kind.

To keep the blend, save and restore it one of two ways, client side, on the vehicle entity.

Exports (recommended)

--Saving, before the vehicle is stored
local fuel = {
    level = exports.refuelingnozzlesv2:GetFuel(vehicle),  -- 0 - 100
    mix = exports.refuelingnozzlesv2:GetFuelMix(vehicle), -- { ["95"] = 0.7, diesel = 0.3 }
}
--store 'fuel' with the vehicle's other properties

--Restoring, once the vehicle is spawned
exports.refuelingnozzlesv2:SetFuel(vehicle, fuel.level)
exports.refuelingnozzlesv2:SetFuelMix(vehicle, fuel.mix)

Setting the level first and the mix second works for every vehicle: electric vehicles and empty tanks have no mix, and SetFuelMix then simply does nothing. The mix keys are plain strings ("95", "diesel"), so it saves to JSON as it is.

GetFuelType(vehicle) gives the fuel the tank mostly holds, if your garage only has room for one value.

Decors

Next to _FUEL_LEVEL, every petrol and diesel fuel has a float decor named Config.FuelMixDecor + its id:

  • _FUEL_MIX_95
  • _FUEL_MIX_98
  • _FUEL_MIX_diesel

Each is the percent of the tank's contents that is that fuel (0 – 100), kept up to date on every tank change. A garage that saves these decors and sets them again — together with _FUEL_LEVEL — on the new vehicle before the script first touches it (right after spawning it, before a player gets in) gets the blend back.

Without either

The car comes back with the saved level of its engine's own fuel. A car with no saved level at all — no decor, no export call — starts with a random 20 – 80% tank the first time the script sees it.

Get the scriptGet Refueling NozzlesFiveM Fuel Script →
Can't find what you need? Ask on Discord — response in under 5 hours.