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

@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?

1 Like

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?

Howto edit the distance of the text??

Now u need to have the vehicle almost park to the fueler, is it possible to set the text
further away

i think you need to edit a lot more of code, check your db and add a fuel colum in the owned_vehicles table if its needed, also a lot of sync with the db happens in the server script

After a day i was able to store the fuel data when you store a car with esx_advancegarage, you need to play with events, async and modify everything related to the spawncar section. Now it works like a charm

1 Like

how can i take away the MPH and KPH??

doesnā€™t seem to work any more any help possible

for me the tank is very empty. Can someone tell you why?

did u figure it out?

No I did not, I gave up on it for now so that I could configure other scripts first, Iā€™ll get back to that though.