This page is for developers who want to implement Renewed-Fuel within their resources.
Getters
Client
Statebag: Entity(vehicleId).state.fuel
local vehicle = cache.vehicle -- Ox Lib example
local fuel = Entity(vehicle).state.fuel
-- Optimized statebags method (not recommended in loops)
lib.onCache('vehicle', function(vehicle)
if not vehicle then
return
end
local state = Entity(cache.vehicle).state
print(state.fuel)
end)
-- Best way
lib.onCache('vehicle', function(vehicle)
if not vehicle then
return
end
SetTimeout(0, function()
while cache.vehicle do
print(GetVehicleFuelLevel(cache.vehicle))
Wait(100)
end
end)
end)
local vehicle = GetVehiclePedIsIn(GetPlayerPed(source))
exports['Renewed-Fuel']:SetFuel(vehicle, amount, fuelType)
Gas Station exports
Get the gas station tank storage
local Storage = exports['Renewed-Fuel']:GetStorage(StationId, tankId)
-- Station ID is the ID in the db, the tankId, is 1-4 depending on how many tanks the station have
Set the gas station tank storage
exports['Renewed-Fuel']:SetStorage(StationId, tankId, amount, fuelType)
-- Station ID is the ID in the db, tankId is 1-4 depending how many tanks the station have