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


#190

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


#191

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 ?


#192

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

#193

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


#194

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


#196

Gasoline pumps for boats and airplanes.

Postos-de-combustiveis.rar (3.0 KB)


#197

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


#198

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 ?


#199

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)

#200

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


#201

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


#202

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.


#203

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


#204

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


#205

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.


#206

are you using the stand-alone or ESX version?


#207

stand alone


#208

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?


#209

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


#210

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.