OrigenNetwork
Docs

Custom · origen_hud

The custom/ folder contains open-source files that can be modified to integrate third-party resources. These files are excluded from escrow.

text
custom/
└── functions.lua

custom/functions.lua

This file defines the fuel retrieval logic used by the vehicle HUD. Modify it to add support for additional fuel systems.

GetFuel(vehicle) → number

Returns the current fuel level of the given vehicle. The behavior depends on Config.FuelSystem.

Config.FuelSystemBehavior
"standalone"Returns native GTA V fuel via GetVehicleFuelLevel(vehicle).
"legacyfuel"Calls exports['LegacyFuel']:GetFuel(vehicle).
lua
function GetFuel(vehicle)
    if Config.FuelSystem == "legacyfuel" then
        return exports['LegacyFuel']:GetFuel(vehicle)
    elseif Config.FuelSystem == "standalone" then
        return GetVehicleFuelLevel(vehicle)
    else
        print("^4[ORIGEN HUD] ^1 ERROR: ^7Invalid fuel system specified in config.lua")
        return 0
    end
end

Adding a custom fuel system

To integrate a different fuel resource, add a new condition to GetFuel:

lua
function GetFuel(vehicle)
    if Config.FuelSystem == "legacyfuel" then
        return exports['LegacyFuel']:GetFuel(vehicle)
    elseif Config.FuelSystem == "myCustomFuel" then
        return exports['my-fuel-resource']:GetFuel(vehicle)
    elseif Config.FuelSystem == "standalone" then
        return GetVehicleFuelLevel(vehicle)
    else
        print("^4[ORIGEN HUD] ^1 ERROR: ^7Invalid fuel system specified in config.lua")
        return 0
    end
end

Then set Config.FuelSystem = "myCustomFuel" in config.lua.

The function must always return a numeric value between 0 and 100. Returning nil or a non-numeric value will cause the fuel bar to display incorrectly.