[Release] [ESX & Non-ESX] LegacyFuel system


I need to find where i change the name of fuel and mph on the hud. Thanks!


WHY is it not working for me. i put de esx_legacyfuel in de resource folder and start esx_legacyfuel in de server.cfg and nothing works. i am on an ESX based server. legacyfuel non-esx based starts up. but i want the esx one cause of the payment. what do i wrong ?


to put the vehicle on the blacklist you have to edit this, and where to pick up those numbers

models = {
	[1] = -2007231801,
	[2] = 1339433404,
	[3] = 1694452750,
	[4] = 1933174915,
	[5] = -462817101,
	[6] = -469694731,
	[7] = -164877493

blacklistedVehicles = {
	[1] = 'BMX',
	[2] = 'CRUISER',
	[3] = 'FIXTER',
	[4] = 'SCORCHER',
	[5] = 'TRIBIKE',
	[6] = 'TRIBIKE2',
	[7] = 'TRIBIKE3'


I am not able to supply the boats and airplanes with Gallon of fuel


did you put the right file in your resource folder? cause it has 2 versions just recheck it and make sure you put the esx version cause it works fine


Gasoline pumps for boats and airplanes.

Postos-de-combustiveis.rar (3.0 KB)


do not give to supply the planes and boats with gallon of gasoline.


How am I able to change the fuel consumption from the cars?
The people in my server are complaining about the fuel that its draining toooo fast :confused:
Where do I need to change in the files ?


Look in client/main.lua

	while true do

		local vehicle = GetVehiclePedIsIn(GetPlayerPed(-1))
		local engine  = Citizen.InvokeNative(0xAE31E7DF9B5B132E, vehicle)

		if vehicle and engine then
			local plate    	   = GetVehicleNumberPlateText(vehicle)
			local rpm 	   	   = GetVehicleCurrentRpm(vehicle)
			local fuel     	   = GetVehicleFuelLevel(vehicle)
			local rpmfuelusage = 0

			if rpm > 0.9 then
				rpmfuelusage = fuel - rpm / 0.8
			elseif rpm > 0.8 then
				rpmfuelusage = fuel - rpm / 1.1
			elseif rpm > 0.7 then
				rpmfuelusage = fuel - rpm / 2.2
			elseif rpm > 0.6 then
				rpmfuelusage = fuel - rpm / 4.1
			elseif rpm > 0.5 then
				rpmfuelusage = fuel - rpm / 5.7
			elseif rpm > 0.4 then
				rpmfuelusage = fuel - rpm / 6.4
			elseif rpm > 0.3 then
				rpmfuelusage = fuel - rpm / 6.9
			elseif rpm > 0.2 then
				rpmfuelusage = fuel - rpm / 7.3
				rpmfuelusage = fuel - rpm / 7.4

			for i = 1, #Vehicles do
				if Vehicles[i].plate == plate then
					SetVehicleFuelLevel(vehicle, rpmfuelusage)

					local updatedfuel = round(GetVehicleFuelLevel(vehicle), 1)

					if updatedfuel ~= 0 then
						TriggerServerEvent('LegacyFuel:UpdateServerFuelTable', plate, updatedfuel)

						table.remove(Vehicles, i)
						table.insert(Vehicles, {plate = plate, fuel = rpmfuelusage})


			if rpmfuelusage < Config.VehicleFailure then
				SetVehicleUndriveable(vehicle, true)
			elseif rpmfuelusage == 0 then
				SetVehicleEngineOn(vehicle, false, false, false)
				SetVehicleUndriveable(vehicle, false)


Yea Thx Btw! I just saw this and I already Tripled those values and now its perfect :wink: !


All the stock gta v aircraft are unflyable with this script enabled. it constantly breaks the engine. Anyone know a fix?


I would suggest just adding a check for vehicle class see GetVehicleClass

you can probably add it here

check for class 15/16 (airplanes & helicopters), and anything else you don’t want it to effect for that matter.


What if I want it for helicopters and planes just dont want them to break?


Code probably needs to be reworked for different vehicle classes.

best guess would be that the RPM of aircraft is much higher so you’d need to change the rate of fuel consumption? or give them a lot more fuel to start with


Ok, as per your suggestion, could you maybe write it out for me? sorry I know nothing about coding, I can only read bits and pieces of it. My extent is changing keybindings and some other small stuff lol.


are you using the stand-alone or ESX version?


stand alone


sure, it might take a couple days with testing but I’ll have a look.

jets may be tricky, I’m not sure the RPM fuel math will work so well there.

are there specific aircraft you’re most interested in?


Wait, are you adding them to the fuel script or taking them out?


I’m open to trying to make it work with vehicles just saying jets may be … interesting.

and asking which aircraft you are most interested in, I will start testing with those.

Basically I expect as I said that we’ll have to come up with some new math for fuel usage for aircraft generally, and probably different math for jets.