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

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'
}
1 Like

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

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(5000)

		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
				Citizen.Wait(1000)
			elseif rpm > 0.8 then
				rpmfuelusage = fuel - rpm / 1.1
				Citizen.Wait(1500)
			elseif rpm > 0.7 then
				rpmfuelusage = fuel - rpm / 2.2
				Citizen.Wait(2000)
			elseif rpm > 0.6 then
				rpmfuelusage = fuel - rpm / 4.1
				Citizen.Wait(3000)
			elseif rpm > 0.5 then
				rpmfuelusage = fuel - rpm / 5.7
				Citizen.Wait(4000)
			elseif rpm > 0.4 then
				rpmfuelusage = fuel - rpm / 6.4
				Citizen.Wait(5000)
			elseif rpm > 0.3 then
				rpmfuelusage = fuel - rpm / 6.9
				Citizen.Wait(6000)
			elseif rpm > 0.2 then
				rpmfuelusage = fuel - rpm / 7.3
				Citizen.Wait(8000)
			else
				rpmfuelusage = fuel - rpm / 7.4
				Citizen.Wait(15000)
			end

			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})
					end

					break
				end
			end

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

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

https://github.com/InZidiuZ/LegacyFuel/blob/master/LegacyFuel/client/main.lua#L516

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.

The aircraft I’m most interested in is…Short answer most if not all. Long answer we use civ, police, and military aircraft on a regular basis so…yeah. But if your going to start with anything, the police helicopter. Do you have a discord? It will be easier for me to talk on there.

Does this work for vrp?
Like vrp gas station scripts are not that good