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

Ok try this version.
removed

I went and deleted my forked version then i reforked and use the version from there cause i had a dif version and forgot about it.
So now it should have hud and all that.
Let me know if this version works. It should show in L until it hit the petrol max tank Most car are 65 so if your at 20 that mean your at 20 L not 20% and then when you fuel it will go from 20 to 65 if the max petrol tank is 65L

still brakes the script. i can start fueling a car but it removes the hud when done and can still only fuel a car once after that the pumps dont work anymore

The thing is that it’s the exact same code as the esx. Same place same everything. And works fine on esx. So i am really not sure. Check for errors in console. Maybe there is some error that will tell whats going on.

Ok found the error.
Will have new version very soon @Peter

Legacyfuel normal version. If anyone can test and let me know.
LegacyFuel.rar (5.4 KB)

1 Like

Hi, which file and line to set fuel usage while driving? somehow its too fast

This code 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 / 1.8
				Citizen.Wait(1000)
			elseif rpm > 0.8 then
				rpmfuelusage = fuel - rpm / 2.1
				Citizen.Wait(1500)
			elseif rpm > 0.7 then
				rpmfuelusage = fuel - rpm / 3.2
				Citizen.Wait(2000)
			elseif rpm > 0.6 then
				rpmfuelusage = fuel - rpm / 5.1
				Citizen.Wait(3000)
			elseif rpm > 0.5 then
				rpmfuelusage = fuel - rpm / 6.7
				Citizen.Wait(4000)
			elseif rpm > 0.4 then
				rpmfuelusage = fuel - rpm / 7.4
				Citizen.Wait(5000)
			elseif rpm > 0.3 then
				rpmfuelusage = fuel - rpm / 7.9
				Citizen.Wait(6000)
			elseif rpm > 0.2 then
				rpmfuelusage = fuel - rpm / 8.3
				Citizen.Wait(8000)
			else
				rpmfuelusage = fuel - rpm / 8.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)

This is the one i use and it’s pretty decent. Try it and if you don’t like it just edit it.

2 Likes

Video

This version is almost the original version with few edit.

What’s been edited:

  • Hud now display L next to fuel number Example 28L
  • While fueling will display L example 28L until full
  • Will use maxfuel from petrol tank which is handling file.
  • Most vehicle has 65 but few have more or less.
  • Will show vehicle is too filled base on the vehicle petrol tank.
  • Vehicle will now spawn with vehicle between 20L and 60 L

Download Below
Normal version and esx version are edited. I can do vrp but i would need a tester before i push this on github.

So… put a gas pump in game, put the correct coords in (as shown in screenshot with minimap blip) deleted servery cache, restarted server, but still no prompts to fuel the boat. If i no-clip the boat to the gas station nearby it works at the pump, but for whatever reason mine is not? Any help would be appreciated.

Image from Gyazo

Make sure to have the proper hash in the

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

I know it seem to be same as other but it might not be the same hash number.

Thanks @XxFri3ndlyxX I’ll use a model I know works and see if it resolves it.

Alright let me know if it works. :slight_smile:

Has anyone managed to get to pick up the gallon of fuel at the pump?

where can i buy jerrycans?

Just put them in shop and buy it.

When you put in the store to buy jerrycans when trying to use it to fuel the vehicle it does not come with capacity to fuel.

Where and how can I change the place of the hud, I will have it in the right corner, can you help me please?

Hey, does it matter if the model is dynamic or not? Turns out 19331474915 is listed.

jerrycans when trying to use it to fuel the vehicle it does not come with capacity to fuel.

Is there a way to disable repairing a vehicle via a trainer from adding more fuel?

@CLOS @RPPerry3 To be honest i dont use jerry can but when i tested it it was via vmenu spawned the weapon gas and it was working. I will add the gas canister to my shop and do a test.

Alright well since my friend said it want jerry can to be added. Your all in luck i started work on adding it.
Now it will remove 100$ to fill your jerrycan and a notification will be displayed.
If you do not have cash then you cant fill your jerrycan same goes if you don’t have it equipped.
If your jerrycan is full then you cant fill it or pay.

Screenshot


Jerry Can Video

https://youtu.be/tgwrP7scPBQ

4 Likes