inzidiuz / legacyfuel Goto Github PK
View Code? Open in Web Editor NEWA simple, lightweight fuel script for FiveM
License: GNU General Public License v3.0
A simple, lightweight fuel script for FiveM
License: GNU General Public License v3.0
Hello. I called the exports to set the fuel when vehicle spawns on eden garage
I tried all and nothing works.
My script it's called LegacyFuel
I tried:
local car = GetClosestVehicle(this_Garage.SpawnPoint.Pos.x ,this_Garage.SpawnPoint.Pos.y,this_Garage.SpawnPoint.Pos.z + 1, 3.0, 0, 71)
exports["LegacyFuel"]:SetFuel(vehicle, 100)
exports.LegacyFuel:SetFuel(vehicle, 100)
exports.LegacyFuel:SetFuel(car, 100)
Nothing happens. Still spawning the vehicle with random fuel number.
Hi!
After some people have fueled their vehicles, the fuel lvl gets the same as it was before in just a couple of seconds / minutes. It's not that it's dropping because they are driving, it just randomly drops from example 50 to 18. Sync problem?
Fuel is set up randomly when we hide and then we take the vehicle out of the garage.
Is there any solution i can use in esx_eden_garage?
alot of people say when they are taking the dmv driving test they run out of fuel, is there a way to block the dmv vehicles without blocking the entire model
Hello, i have a big problem with your script here is the bug :
https://www.youtube.com/watch?v=z_2F6vRYtZk&feature=youtu.be
I had never had this problem, it appeared overnight ...
and now when i try to refill a car it's very buggy
Hello, i have set on all cars 0.2 fuel, but it still go so fast, one second, one fuel. Config:
Config = {}
-- Are you using ESX? Turn this to true if you would like fuel & jerry cans to cost something.
Config.UseESX = true
-- What should the price of jerry cans be?
Config.JerryCanCost = 100
Config.RefillCost = 50 -- If it is missing half of it capacity, this amount will be divided in half, and so on.
-- Fuel decor - No need to change this, just leave it.
Config.FuelDecor = "_FUEL_LEVEL"
-- What keys are disabled while you're fueling.
Config.DisableKeys = {0, 22, 23, 24, 29, 30, 31, 37, 44, 56, 82, 140, 166, 167, 168, 170, 288, 289, 311, 323}
-- Want to use the HUD? Turn this to true.
Config.EnableHUD = true
-- Configure blips here. Turn both to false to disable blips all together.
Config.ShowNearestGasStationOnly = false
Config.ShowAllGasStations = true
-- Modify the fuel-cost here, using a multiplier value. Setting the value to 2.0 would cause a doubled increase.
Config.CostMultiplier = 1.0
-- Configure the strings as you wish here.
Config.Strings = {
ExitVehicle = "Exit the vehicle to refuel",
EToRefuel = "Press gE wto refuel vehicle",
JerryCanEmpty = "Jerry can is empty",
FullTank = "Tank is full",
PurchaseJerryCan = "Press gE wto purchase a jerry can for g$" .. Config.JerryCanCost,
CancelFuelingPump = "Press gE wto cancel the fueling",
CancelFuelingJerryCan = "Press gE wto cancel the fueling",
NotEnoughCash = "Not enough cash",
RefillJerryCan = "Press gE w to refill the jerry can for ",
NotEnoughCashJerryCan = "Not enough cash to refill jerry can",
JerryCanFull = "Jerry can is full",
TotalCost = "Cost",
}
if not Config.UseESX then
Config.Strings.PurchaseJerryCan = "Press gE wto grab a jerry can"
Config.Strings.RefillJerryCan = "Press gE w to refill the jerry can"
end
Config.PumpModels = {
[-2007231801] = true,
[1339433404] = true,
[1694452750] = true,
[1933174915] = true,
[-462817101] = true,
[-469694731] = true,
[-164877493] = true
}
-- Blacklist certain vehicles. Use names or hashes. https://wiki.gtanet.work/index.php?title=Vehicle_Models
Config.Blacklist = {
--"Adder",
--276773164
}
-- Do you want the HUD removed from showing in blacklisted vehicles?
Config.RemoveHUDForBlacklistedVehicle = true
-- Class multipliers. If you want SUVs to use less fuel, you can change it to anything under 1.0, and vise versa.
Config.Classes = {
[0] = 0.2, -- Compacts
[1] = 0.2, -- Sedans
[2] = 0.2, -- SUVs
[3] = 0.2, -- Coupes
[4] = 0.2, -- Muscle
[5] = 0.2, -- Sports Classics
[6] = 0.2, -- Sports
[7] = 0.2, -- Super
[8] = 0.2, -- Motorcycles
[9] = 0.2, -- Off-road
[10] = 0.2, -- Industrial
[11] = 0.2, -- Utility
[12] = 0.2, -- Vans
[13] = 0.0, -- Cycles
[14] = 0.2, -- Boats
[15] = 0.2, -- Helicopters
[16] = 0.2, -- Planes
[17] = 0.2, -- Service
[18] = 0.2, -- Emergency
[19] = 0.2, -- Military
[20] = 0.2, -- Commercial
[21] = 0.2, -- Trains
}
-- The left part is at percentage RPM, and the right is how much fuel (divided by 10) you want to remove from the tank every second
Config.FuelUsage = {
[0.2] = 0.2,
[0.9] = 0.2,
[0.8] = 0.2,
[0.7] = 0.2,
[0.6] = 0.2,
[0.5] = 0.2,
[0.4] = 0.2,
[0.3] = 0.2,
[0.2] = 0.2,
[0.1] = 0.1,
[0.0] = 0.0,
}
Config.GasStations = {
vector3(49.4187, 2778.793, 58.043),
vector3(263.894, 2606.463, 44.983),
vector3(1039.958, 2671.134, 39.550),
vector3(1207.260, 2660.175, 37.899),
vector3(2539.685, 2594.192, 37.944),
vector3(2679.858, 3263.946, 55.240),
vector3(2005.055, 3773.887, 32.403),
vector3(1687.156, 4929.392, 42.078),
vector3(1701.314, 6416.028, 32.763),
vector3(179.857, 6602.839, 31.868),
vector3(-94.4619, 6419.594, 31.489),
vector3(-2554.996, 2334.40, 33.078),
vector3(-1800.375, 803.661, 138.651),
vector3(-1437.622, -276.747, 46.207),
vector3(-2096.243, -320.286, 13.168),
vector3(-724.619, -935.1631, 19.213),
vector3(-526.019, -1210.203, 18.184),
vector3(-70.2148, -1761.792, 29.534),
vector3(265.648, -1261.309, 29.292),
vector3(819.653, -1028.846, 26.403),
vector3(1208.951, -1402.567,35.224),
vector3(1181.381, -330.847, 69.316),
vector3(620.843, 269.100, 103.089),
vector3(2581.321, 362.039, 108.468),
vector3(176.631, -1562.025, 29.263),
vector3(176.631, -1562.025, 29.263),
vector3(-319.292, -1471.715, 30.549),
vector3(1784.324, 3330.55, 41.253)
}
The problem has persisted after I updated. If you walk up and buy a jerrycan it gives it to you and takes $100, but if you keep hitting E it continues to take $100 each time.
The script doesn't detect if the car is electric or not and still add gas to it
I was wondering if this is with superhud and can i remove the display showing the gas
SCRIPT ERROR: @LegacyFuel/source/fuel_server.lua:8: attempt to index a nil value (global 'ESX')
pls help
Re-implement a blacklist system allowing you to exclude certain vehicles from the fueling system.
Anytime a damaged vehicle is repaired, the fuel level is set to 65.
Updated to the new version, and now there is no HUD and the Gas Station Blips are missing.
You can no longer blacklist certain vehicles, meaning electric vehicles now use gas
Can you make the engine cutting out at 10 fuel toggle-able in the config? I want to turn it off.
How can i change fuel price ? i tried everything but i can't...
Anyway to fix the usage rate of the jerry can so that it isn't left with like 40 fuel at the end? This will make players have to drop the item before buying another one instead of it just being completely used up.
E doesnt work anymore to cancel fueling since the latest update.
Seem to be having a detection issue, Players are seeing the prompt "Exit to refuel" when pulling up however when exiting they do not get an option to refuel, however can purchase Jerry Cans.
They also cannot always use Jerry Cans, sometimes the option is present, other times it is not.
I will do more testing in case it is at certain Gas Stations however I know one we have been having issue with is the LTD Gasoline near the Vanilla Unicorn.
Cant refill jerrycan unless you have $100 on you.
ESX.GetPlayerData().money
That function was removed in latest ESX, thats why
so , after refilling car , (jerrycans most of the time) , characters get freeze,cant get inside car , cant access phone , cant do anything at all
but after you drop jerrycan , everything will work fine
tried to remove disablecontrol, nothing good happend
Hello,
I'm on the latest version and whenever there are multiple people in the vehicle and you attempt to refuel it, the fuel gets set back to whatever it was prior to fueling it. Seems to be a client sync issue potentially. Works fine if no one is in the vehicle with you while you are refueling.
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')
stack traceback:
@LegacyFuel/source/fuel_server.lua:8: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:219: in function citizen:/scripting/lua/scheduler.lua:218
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:218: in function citizen:/scripting/lua/scheduler.lua:182
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')
stack traceback:
@LegacyFuel/source/fuel_server.lua:8: in upvalue 'handler'
citizen:/scripting/lua/scheduler.lua:219: in function citizen:/scripting/lua/scheduler.lua:218
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
citizen:/scripting/lua/scheduler.lua:218: in function citizen:/scripting/lua/scheduler.lua:182
Hello, i have installed LegacyFuel and ESX_AdvancedFuel succesfully. but when you put your vehicle in your garage, and you take it back, the fuel reset. How to save the fuel or something?
-Deleted-
Is there any way I can add this in gta5 single player ? Would love to use it in story mode , thanks
Got an error when taking a car out of my garage:
Error resuming coroutine: @LegacyFuel/source/fuel_client.lua:30: attempt to perform arithmetic on a nil value (field '?')
stack traceback:
@LegacyFuel/source/fuel_client:30: in function 'ManageFuelUsage'
@LegacyFuel/source/fuel_client:64: in function <@LegacyFuel/source/fuel_client.lua:34>
It is not normal, it sometimes skipped some numbers. Tried to edit the config and still nothings is changed. Thank you for your help.
After i upgraded my artifacts to 2270 fuel consumption is not working,.
Cannot get exports "No such export GetFuel in resource LegacyFuel" . I don't know, I'm dumb or I'm wrong
Error running call reference function for resource esx_advancedgarage: citizen:/scripting/lua/scheduler.lua:405: citizen:/scripting/lua/scheduler.lua:762: No such export GetFuel in resource LegacyFuel
stack traceback:
[C]: in function 'error'
citizen:/scripting/lua/scheduler.lua:762: in metamethod '__index'
@esx_advancedgarage/server/main.lua:138: in upvalue 'ref'
citizen:/scripting/lua/scheduler.lua:391: in function citizen:/scripting/lua/scheduler.lua:390
[C]: in function 'xpcall'
citizen:/scripting/lua/scheduler.lua:390: in function citizen:/scripting/lua/scheduler.lua:389
`ESX.RegisterServerCallback('esx_advancedgarage:storeVehicle', function (source, cb, vehicleProps)
local ownedCars = {}
local vehplate = vehicleProps.plate:match("^%s*(.-)%s*$")
local vehiclemodel = vehicleProps.model
local xPlayer = ESX.GetPlayerFromId(source)
local fuelLevel = exports["LegacyFuel"]:GetFuel(source)
MySQL.Async.fetchAll(SELECT * FROM owned_vehicles WHERE owner = @owner AND @plate = plate, {
['@owner'] = xPlayer.identifier,
['@plate'] = vehicleProps.plate
}, function (result)
if result[1] ~= nil then
local originalvehprops = json.decode(result[1].vehicle)
if originalvehprops.model == vehiclemodel then
MySQL.Async.execute('UPDATE owned_vehicles SET vehicle = @vehicle WHERE owner = @owner AND plate = @plate AND fuel = @fuel', {
['@owner'] = GetPlayerIdentifiers(source)[1],
['@vehicle'] = json.encode(vehicleProps),
['@plate'] = vehicleProps.plate,
['@fuel'] = vehicleProps.fuelLevel
}, function (rowsChanged)
if rowsChanged == 0 then
print(('esx_advancedgarage: %s attempted to store an vehicle they don\'t own!'):format(GetPlayerIdentifiers(source)[1]))
end
cb(true)
end)
else
if Config.KickPossibleCheaters == true then
if Config.UseCustomKickMessage == true then
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
DropPlayer(source, _U('custom_kick'))
cb(false)
else
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
DropPlayer(source, 'You have been Kicked from the Server for Possible Garage Cheating!!!')
cb(false)
end
else
print(('esx_advancedgarage: %s attempted to Cheat! Tried Storing: '..vehiclemodel..'. Original Vehicle: '..originalvehprops.model):format(GetPlayerIdentifiers(source)[1]))
cb(false)
end
end
else
print((esx_advancedgarage: %s attempted to store an vehicle they don\t own!):format(GetPlayerIdentifiers(source)[1]))
cb(false)
end
end)
end)
`
There is a problem with the blacklisted vehicle..
I know we can't refuel helicopter, airplane, boat..
But they still use gas and it will reach 0% at some point and we're stuck there..
Even tho we add the gamename inside the blacklistvehicle the text will disapear but they will continue to use gas..
the solution i found for the moment is to edit every boat, airplane, helicopter handling files and set :
<fPetrolTankVolume value="0.000000" />
<fOilVolume value="0.000000" />
Hi,
This a bug report. When you fill up you vehicle tank to 100 and you use fixkit to repair your vehicle. The fuel meter shows to you 65.
Hi there. Having an issue with money not deducting with ESX. Using your latest update, and yes I have ESX installed correctly. Your old version (the original esx_legacyfuel) used to work fine.
Here's the error it throws:
Error running system event handling function for resource esx_legacyfuel: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: @esx_legacyfuel/source/fuel_server.lua:9: attempt to index a nil value (field 'Math') stack traceback: @esx_legacyfuel/source/fuel_server.lua:9: in upvalue 'handler' citizen:/scripting/lua/scheduler.lua:219: in function <citizen:/scripting/lua/scheduler.lua:218> stack traceback: [C]: in function 'error' citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow' citizen:/scripting/lua/scheduler.lua:218: in function <citizen:/scripting/lua/scheduler.lua:182>
when i enter in a car the fuel goes completely wild (it goes from 70 to 20 then again to 90 etc...)
i don't realy know how to fix that... same when i am trying to refill y car it fills endless...
if someone has an idea how to fix this it would be nice :D
I downloaded the latest version if the car is not empty (i mean if there are some people in it ), the fuel level is not increasing. Any fixes for that ?
yes I have Config.UseESX = true
When I refuel or buy jerrycan it doesnt take my money
When disabling either kmh or mph in fuel_client.lua, they display oposite, like mph displays kmh, and kmh displays mph, seems like local kmh and local mph are switched, possibly on the math.ceil lines.
Not a big issue though, just something to be aware of :)
Hey i get this error when i load ur resources whit out any confiq.
client276: attempt to compare number with nil
@legacyfuel/source/fuel_client.lua276: in function <@LegacyFuel/source/fuel_client.lua:247>
If you get your vehicle out of your garage the first time it will have gas...
if you put your vehicle inside your garage and retake it.. it has 0% gas
Player can buy fuel without pay money by spamming button (default button is "E") .
Hi,
I'm really sorry to bother you with this, but i don't understand how to use the exports.
Thanks
When you have low fuel on the vehicle (less then 10%) it will start fail the engine, that's ok...
the problem is when you actually stop the car at low fuel, if you try to move forward the wheels will be locked and the car will move backwards (like if it's breaking, but because the car isn't moving it start to move backwards)
Hi,
Boats can go to 0 and still continue
wont take money from my bank or cash any ideas?
The jerrycan needs a check if you already have one and if you have the cash. Currently you can spam it into negative cash. You can also buy one if you already have one which doesnt do anything.
Electric vehicles do not affect running out of gasoline.
Sync does not work correct.
When someone enters my vehicle, it sometimes has a different amount of fuel.
We are changing over from FRFuel to LegacyFuel for our new ESX server we are setting up. One thing I see is the lack of fueling support for helicopters. With FRFuel, we could define points specifically for fueling helicopters at airfields/helipads even though there are not any pumps. It also supports designating tanker trucks in the config to be able to fuel helicopters anywhere.
I was looking through the code for LegacyFuel and see where it is looking for pumps nearby (I assume it's looking for the pump prop?) so just adding locations at helipads I don't think will work since there are no pumps.
I was wondering if it would be possible to add support for non pump areas to be added for fueling helicopters or adding the possibility to set in the config the ability for certain tankers to be able to provide fuel.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.