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

F8 ingame says:
Script Error: @legacy fuel/source/fuel client.lua:297: attempt to compare number with nil
when i stay with a vehicle in the near i cant fuel up the vehicle or buy a gascan .

Anybody know why ?

line 247 to 346 from legacy fuel/source/fuel client.lua

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

		local ped = PlayerPedId()

		if not isFueling and ((isNearPump and GetEntityHealth(isNearPump) > 0) or (GetSelectedPedWeapon(ped) == 883325847 and not isNearPump)) then
			if IsPedInAnyVehicle(ped) and GetPedInVehicleSeat(GetVehiclePedIsIn(ped), -1) == ped then
				local pumpCoords = GetEntityCoords(isNearPump)

				DrawText3Ds(pumpCoords.x, pumpCoords.y, pumpCoords.z + 1.2, Config.Strings.ExitVehicle)
			else
				local vehicle = GetPlayersLastVehicle()
				local vehicleCoords = GetEntityCoords(vehicle)

				if DoesEntityExist(vehicle) and GetDistanceBetweenCoords(GetEntityCoords(ped), vehicleCoords) < 2.5 then
					if not DoesEntityExist(GetPedInVehicleSeat(vehicle, -1)) then
						local stringCoords = GetEntityCoords(isNearPump)
						local canFuel = true

						if GetSelectedPedWeapon(ped) == 883325847 then
							stringCoords = vehicleCoords

							if GetAmmoInPedWeapon(ped, 883325847) < 100 then
								canFuel = false
							end
						end

						if GetVehicleFuelLevel(vehicle) < 95 and canFuel then
							if currentCash > 0 then
								DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.EToRefuel)

								if IsControlJustReleased(0, 38) then
									isFueling = true

									TriggerEvent('fuel:refuelFromPump', isNearPump, ped, vehicle)
									LoadAnimDict("timetable@gardener@filling_can")
								end
							else
								DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.NotEnoughCash)
							end
						elseif not canFuel then
							DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.JerryCanEmpty)
						else
							DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.FullTank)
						end
					end
				elseif isNearPump then
					local stringCoords = GetEntityCoords(isNearPump)

					if currentCash >= Config.JerryCanCost then
						if not HasPedGotWeapon(ped, 883325847) then
							DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.PurchaseJerryCan)

							if IsControlJustReleased(0, 38) then
								GiveWeaponToPed(ped, 883325847, 4500, false, true)

								TriggerServerEvent('fuel:pay', Config.JerryCanCost)

								currentCash = ESX.GetPlayerData().money
							end
						else
							if Config.UseESX then
								local refillCost = Round(Config.RefillCost * (1 - GetAmmoInPedWeapon(ped, 883325847) / 4500))

								if refillCost > 0 then
									if currentCash >= refillCost then
										DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.RefillJerryCan .. refillCost)

										if IsControlJustReleased(0, 38) then
											TriggerServerEvent('fuel:pay', refillCost)

											SetPedAmmo(ped, 883325847, 4500)
										end
									else
										DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.NotEnoughCashJerryCan)
									end
								else
									DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.JerryCanFull)
								end
							else
								DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.RefillJerryCan)

								if IsControlJustReleased(0, 38) then
									SetPedAmmo(ped, 883325847, 4500)
								end
							end
						end
					else
						DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.NotEnoughCash)
					end
				else
					Citizen.Wait(250)
				end
			end
		else
			Citizen.Wait(250)
		end
	end
end)

I have this like error when i use legacyfuel none of my other UI’s work? When i enter a car i can’t use the Q menu for radios and when i leave i can’t use TAB menu for weapons etc. I have tested and IT IS legacyfuel that is causing it.

I use the vRP framework any ideas anyone?
Thanks :slight_smile:

Is there a way to change the Gas HUD so its the bar like FR fuel has but the same refill process as this?

Why not just use FR fuel then? lmfao

function SpawnVehicle(modelHash)
local vehicle = CreateVehicle(modelHash, coords.x, coords.y, coords.z, true, false)

exports["LegacyFuel"]:SetFuel(vehicle, 100)

end

function StoreVehicleInGarage(vehicle)
local plate = GetVehicleNumberPlateText(vehicle)
local fuelLevel = exports[“LegacyFuel”]:GetFuel(vehicle)

TriggerServerEvent('vehiclesStored', plate, fuelLevel)

end

where i should add tihs?

3 Likes

Is there a way to remove the hud?

I got it sorry

Hi. How can i fix this for sexyspeedoemeter, please?

change in speedometer script FuelDecor = “_FUEL_LEVEL”

yo im making a menu based server, doesnt work for me for some reason, i put the legacyfuel-master.zip in the resources and put start legacyfuel in server.cfg

Anyone know how to fix the bug where it sets your vehicle fuel to 65 when you repair your vehicle?

is there a version of this with just the fuel ? i just finished customising realisticvehiclefailure and dont wanna screw around to get this one to work just want the fuel.

Hey. Is there a way to set it up to where you need to get the vehicle and refuel, but it would show the popup, instead of 3d text?

1 Like

how to save fuel with esx_advancedgarage?

how can i change the size and color of the gas station blips in the map?

Hi thanks for the release! Is there a way to prevent the gas station from exploding when being hit by a vehicle? Some of my players when they get near the gas pump it explodes randomly. Thank you

Hi, I have configured the fuel usage and it consumes the same, how can I reduce it?

1 Like

Idk, it can be because of some syncing issues. An easy fix, is to use this:

2 Likes

how can i change the color of this?
https://gyazo.com/54b3b77b91bc59ab1c6a2eba91fe1b28

For some reason I just cannot get this resource to use fuel on my server, It works fine with normal GTA vehicles, but a big nope to add-on’s.

Would rather use the new as opposed to the old esx_ model, but - I gotta do what I gotta do I guess.