Skip to content

Electric vehicles

Tell Aurora HUD which vehicles are electric, and patch ox_fuel so regenerative braking charges the battery.

An electric vehicle shows a battery and a power meter instead of a fuel gauge and a rev counter. Both settings live in /hud → Admin → Vehicles.

Automatic detection is on by default. It reads the game’s own flag, which is correct for base-game electric cars and requires game build 3258 or newer. Add-on models rarely carry the flag, so they need one of two lists, one spawn name per line:

List For
Force Electric Models to always treat as electric
Force Combustion Models wrongly flagged electric
Rule
Precedence Force Combustion wins over Force Electric
Bicycles never electric, whatever the lists say
List size 200 models each
Name format spawn name: letters, digits, -, _; 32 characters maximum

With automatic detection off, the lists are the only source.

Off by default. It is the one feature that requires editing another resource’s file.

GTA V has no battery: electric vehicles use the same fuel field as petrol cars, and nothing in the game adds to it. The work is therefore split: the HUD measures the braking, and ox_fuel owns and writes the fuel value. The bridge is a read-and-clear export, so the two never write the same value and a missed call cannot double-credit.

Two blocks in ox_fuel/client/init.lua.

1. Before local function startDrivingVehicle()

Section titled “1. Before local function startDrivingVehicle()”
ox_fuel/client/init.lua
local AURORA_HUD = 'aurora_hud'
local function auroraRegen()
if not LocalPlayer.state.aurora_ev_regen then return 0 end
local ok, gain = pcall(function() return exports[AURORA_HUD]:ConsumeElectricRegen() end)
return (ok and type(gain) == 'number' and gain > 0) and gain or 0
end

The aurora_ev_regen statebag gates the export call: the HUD sets it only in an electric vehicle with regeneration enabled. The dependency is optional: without the HUD the flag is nil and ox_fuel behaves as before.

2. Inside the driving loop, right after the leaking-tank block

Section titled “2. Inside the driving loop, right after the leaking-tank block”
ox_fuel/client/init.lua
if fuelAmount > 0 then
if GetVehiclePetrolTankHealth(vehicle) < 700 then
newFuel -= math.random(10, 20) * 0.01
end
-- Aurora HUD patch
local regen = auroraRegen()
if regen > 0 then newFuel = math.min(newFuel + regen, 100.0) end

A punctured tank still leaks.

Applied on the HUD side; none of these are configured in ox_fuel.

Limit Value
Ceiling 85% by default. Braking never charges above it
Deceleration cap 8 m/s². Harder braking is clamped, not ignored
Intensity 30% by default: the share of braking energy returned
Speed floor recovers only while slowing, above 2 m/s
Vehicle change pending credit is cleared

The test is whether the motor is braking, not whether the vehicle is slowing. The balance is of forces per unit of mass:

motor = measured acceleration + gravity for/against + drag

Drag is calibrated per vehicle from GetVehicleEstimatedMaxSpeed, since a car at top speed on the flat is by definition at full output. Regeneration is suppressed while the throttle is applied (GetVehicleThrottleOffset).

Situation Readout
Coasting downhill, off the throttle 0%
Downhill braking on the motor −50% · charging
Downhill, throttle floored +100% · consuming
Flat, at top speed, floored +100% · consuming
Uphill at constant speed +58% · consuming

At the default 30% intensity:

Situation Gain
Hard stop, 100 → 0 km/h 0.11% of battery
Gentle stop, 50 → 0 km/h 0.03%
Crashing at 100 km/h 0.11%, the deceleration cap in effect
60 accelerate-brake cycles 1.6%
Descending all of Mount Chiliad (700 m, braking) ~1.7%

The recovered energy is bounded by height, not by time: 700 m of descent is about 6.4% of a battery, of which 30% comes back. Regenerative braking does not replace a charger.