Inicio › Documentación › Personalización · origen_hud
La carpeta custom/ contiene ficheros de código abierto que puedes modificar para integrar recursos de terceros. Estos ficheros están excluidos del escrow.
custom/
└── functions.luaEste fichero define la lógica para obtener el combustible que usa el HUD del vehículo. Modifícalo para añadir compatibilidad con otros sistemas de combustible.
GetFuel(vehicle) → numberDevuelve el nivel de combustible del vehículo indicado. El comportamiento depende de Config.FuelSystem.
Config.FuelSystem |
Comportamiento |
|---|---|
"standalone" |
Devuelve el combustible nativo de GTA V mediante GetVehicleFuelLevel(vehicle). |
"legacyfuel" |
Llama a exports['LegacyFuel']:GetFuel(vehicle). |
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
endPara integrar otro recurso de combustible, añade una condición nueva a GetFuel:
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
endDespués pon Config.FuelSystem = "myCustomFuel" en config.lua.
La función siempre debe devolver un valor numérico entre 0 y 100. Si devuelve nil o un valor no numérico, la barra de combustible se mostrará de forma incorrecta.