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

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:

1 Like

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.

@InZidiuZ can i edit the shit to be like this? 49%20PM

yes, you can edit the shit to be like that

@InZidiuZ how do i edit that shit to be like this shit?

how do i put the belt thing is what im most interested in

How would i go about making this command based insted of using a button

How to remove that speedometer and fuel, whos above the minimap?

After fueling the car it dosnt charge me money …how can I fix that?

Good evening everybody :slight_smile:

I have configured this resource to my liking and everything works like a charm together with every other resource I have. The only thing I would like to do is to save the fuel level when you store a vehicle using a storing resource, in my case “esx_advancedgarage”. I have tried doing it myself already, but I did not succeed. I then googled quite a lot (I was at page 6 of google results multiple times. You don’t want to go there, believe me) and I could simply not find anything. I am pretty new to scripting in general but I’m willing to learn so if anybody would like to explain it to me then I would be incredibly grateful!

So, in my logic I would have to go to the client script of esx_advancedgarage, to the section that gets the vehicle information (model, hash, mods, plate and so on) and just add a function to get the fuel level, then save that to the database with all the other information that is being grabbed. Here’s the piece of code I’d look at:

function StoreOwnedCarsMenu()
	local playerPed  = GetPlayerPed(-1)
	if IsPedInAnyVehicle(playerPed,  false) then
		local playerPed    = GetPlayerPed(-1)
		local coords       = GetEntityCoords(playerPed)
		local vehicle      = GetVehiclePedIsIn(playerPed, false)
		local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
		local current 	   = GetPlayersLastVehicle(GetPlayerPed(-1), true)
		local engineHealth = GetVehicleEngineHealth(current)
		local plate        = vehicleProps.plate
		-- At this point I would add the pre-described function from github
		local fuelLevel    = exports["LegacyFuel"]:GetFuel(vehicle)

So, now that I have that, I need to tell this script to also save that value just a couple lines further down. There is more code to it but I’ve removed that in this thread, I don’t want to bombard you with even more text…

-- Code about repairing vehicle if necessary, else:
else
	putaway(vehicle, vehicleProps, fuelLevel)
	-- Here I have added the fuelLevel value.
end

Once I’ve made these changes I saved everything and fully restarted the server. On startup and joining I’ve not had a single (new) error. However, when I attempted to store a vehicle it did not store the car and threw a script error my way:

SCRIPT ERROR: citizen:/scripting/lua/scheduler.lua:924: No such export GetFuel in resource LegacyFuel
> callback (@esx_menu_default/client/main-lua:50)
error during NUI callback menu_submit: citizen:/scripting/lua/scheduler.lua:807: bad argument #1 to 'unpack' (table expected, got nil)

And at this point I don’t know what to do anymore. Judging from the “No such export” part I would believe that esx_advancedgarage can not ‘reach’ legacyfuel, or legacyfuel has a problem with exports. I have tried starting it before and after esx_advancedgarage, but it did not change anything.

The “table expected, got nil” part might hint that the esx_advancedgarage resource does not know where to save it in the database, which would be a server function. Upon looking into the server main.lua file, I’ve found quite a lot of things, mainly an update function for the vehicles once they are stored. I’ve looked at this in particular:

MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate', {
	['@owner']  = GetPlayerIdentifiers(source)[1],
	['@vehicle'] = json.encode(vehicleProps),
	['@plate']  = vehicleProps.plate
}

I don’t think that the problem is here though. I might have to modify it once esx_advancedgarage can actually read the fuel level but as of right now it seems that it can’t and I also do not feel comfortable screwing with such an important part of the script, since I’ve managed to more or less kill the database before with a similar progress…

So that’s it. That’s my problem, and sorry for the huge wall of text. Any help would be greatly apprechiated, or if it’s even just a modified version of the script, I can look through the changes and learn from them.

Update: Still looking for a solution. I have found some interesting things in es_extended\client\functions.lua:648 stating something about fuel levels but I think that either the garage resource or LegacyFuel would overwrite or not even use that part…

The maximum it gives me is 65, how do I fix it to 100?

That you can not do in this script, you would have to do that in the HUD that you use. If you use “SimpleCarHUD” go to “SimpleCarHUD_cl.lua” and change local fuelShowPercentage = false to true. This might be different depending on which HUD you use.

merci sa a fonctionner pour moi

the same thing happens to me could you solve it?