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

Getting exactly the same error, hope we can have a feedback on this one.

Error running system event handling function for resource LegacyFuel: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: @LegacyFuel/source/fuel_server.lua:8: attempt to index a nil value (upvalue ‘ESX’)

Is there a way that I could move or use a different HUD since other scripts in my server are overlaying it @InZidiuZ ?

d to execute thread: @esx_legacyfuel/source/fuel_server.lua:9: attempt to index a nil value (field 'Math')

who can help us out :smiley:

if Config.UseESX then
	local ESX = nil

	TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

	RegisterServerEvent('fuel:pay')
	AddEventHandler('fuel:pay', function(price)
		local xPlayer = ESX.GetPlayerFromId(source)
		local amount = ESX.Math.Round(price)

		if price > 0 then
			xPlayer.removeMoney(amount)
		end
	end)
end

Does anyone know a fix for the script … i can fuel up my car but it does not remove any money from me even tho it said i owe $40 … nothing was taken out

1 Like

the server i own atm is having a weird bug, some people can refuel but other cant. i was on 30% fuel in my car so i went to refuel but it said i didnt have enough money yet i had 5k. any idea how i could fix this

Cool would be if the fuel is stored in the garage.

is there a way to change the “G” button to something else?

How i can change the random fuel ? please i want to put 50% fuel minimum in all car, because right now i pick the car and i often have 31% fuel i want to put 50% minimum…

please thanks you !

function ManageFuelUsage(vehicle)
	if not DecorExistOn(vehicle, Config.FuelDecor) then
		SetFuel(vehicle, math.random(200, 800) / 10)
	elseif not fuelSynced then
		SetFuel(vehicle, GetFuel(vehicle))

		fuelSynced = true
	end

	if IsVehicleEngineOn(vehicle) then
		SetFuel(vehicle, GetVehicleFuelLevel(vehicle) - Config.FuelUsage[Round(GetVehicleCurrentRpm(vehicle), 1)] * (Config.Classes[GetVehicleClass(vehicle)] or 1.0) / 10)
	end
end

Is that i need to change? SetFuel(vehicle, math.random(200, 800) / 10) ???

thanks you 1

LegacyFuel not syncing other players the fuel level. I see 100 on driver seat, and second seat player see 64 ? How can fix it?

1 Like

How can I add a timer to the fueling process? I’d like it to be much faster.

How I can change cost of fuel?

better late than never. but here.
ESX.Math.Round(price) ESX.Math as far as i can tell does not exist, we dont use it on our server, instead we do math.ceil(price)

you need to set it to SetFuel(vehicle, math.random(500, 800) / 10) as the result will then be no less than 50%.

find chargeToAdd in the client file, and change to what you need, can be a specific amount or what is done here, a random value between 10 and 20, and divided by 10(so 1.0-2.0 pr percent fuel)

I translate the config.strings into other language and it show square boxes in the game

locate fuelToAdd in the client file and change it to what you need, cna be a spcific amount or what is done here, a random value between 10 and 20, and divided by 10(so 1.0-2.0 percent fuel pr tick)

make sure the encoding of the file is correct, for me, i use utf-8, due to Scandinavian letters. otherwise weird symbold and squares show up.

Hey, there’s not
chargeToAdd in the client

maybe you are using an older version of it… the latest version has it. the other version i have(which we switched from to have the jerrycan working) has a local price = 10 to set. still in the client file… . increase or decrease to preference.

its not working still the same probleem :smiley: