[Release] SimpleCarHUD - Standalone Car HUD for Speed, Fuel, Seatbelt, Cruise, Time and Location [v1.30]

About

This is a simple standalone vehicle HUD that is easy to customize and displays the following information when in a vehicle:

  • Speed (MPH or KPH based on game settings)
  • Fuel (as percentage or in liters)
  • Cruise control limiter (CAPSLOCK key or controller A button)
  • Seatbelt (K key or controller DPAD down)
  • Time, heading, street and zone name

Download

Changes

  • VERSION_V1_30

    • Speedometer uses MPH or KPH based on players game settings (settings -> display -> measurement system)
    • Added option to display fuel as percentage
    • Added option to always display location and time
    • Added option to disable controller support
    • Added option to enable/disable exiting the vehicle when seatbelt is on
    • Added seatbelt sound and option to enable/disable
  • VERSION_V1_21

    • Optimized performance ~4x (0.38ms -> 0.09ms with 8700k)
    • Disabled seatbelt for motorcycles
  • VERSION_V1_10

    • Updated HUD layout and colors
    • Updated fuel to use legacy API
    • Added NE, SE, SW, NW headings
    • Updated HUD to only partially show when engine is off or on a bicycle
  • VERSION_V1_00

    • Initial release

Demo

Credit

Cleaned up and optimized code snippets from the following FiveM users

Related Resources

50 Likes

Very nice.

How would I modify it with an API call to another script?

4 Likes

@Brent_Peterson
How can i make that when i press Z the seatbelt goes red and green like switches on and off

how can i decrease the size of the fuel number and speed number?

Modify the SeatbeltIsOn to a TriggerEvent on your belt script

Read through the code, you’ll understand it better

function drawTxt(content, font, colour, scale, x, y)

Now look at the DrawSealtbeltStatus and configure as you go, it’s as easy as that :slight_smile:

1 Like

how to add the api call to the current fuel section of the HUD?

If you learn how to do that, can you tell me? @SXE_Razgriz

Events, look at the fivem docs and read through it

I’ve updated the script to add logic for both seatbelt and cruise control. You can configure what key is used to toggle seatbelt (default is K key) along with minimum speed and G forces to eject player when seatbelt is off. The cruise control is a simple speed limiter and you can configure what key is used (default is CAPLOCK key or controller A button).

Here’s a short demo using cruise to go ~100 MPH and hitting a car with no seatbelt.

GET_VEHICLE_FUEL_LEVEL

// 0x5F739BB8 
// GetVehicleFuelLevel
float GET_VEHICLE_FUEL_LEVEL(Vehicle vehicle);

CitizenFX API set: Client

        -- Draw fuel gauge; always displays 100 but can be modified by setting currentFuel with an API call
        fuelColor = (currentFuel >= fuelWarnLimit) and fuelColorOver or fuelColorUnder
        drawTxt(("%.3d"):format(math.ceil(currentFuel)), 2, fuelColor, 0.8, screenPosX + 0.050, screenPosY + 0.000)
        drawTxt("FUEL", 2, fuelColorText, 0.4, screenPosX + 0.080, screenPosY + 0.020)

– STATE VARIABLES
local currentFuel = 100.0
local cruiseIsOn = false
local seatbeltIsOn = false

Is this how to do it? if so where does it go?

1 Like

It sounds like you can try adding this code before setting fuelColor:

currentFuel = GetVehicleFuelLevel(vehicle)

I haven’t implemented anything with fuel yet so I don’t know if that works, depends on if your fuel system uses the native API. I plan to do it eventually so the HUD element is just a placeholder for now.

Shows current fuel level but it never goes down.

Currently using vRP_AdvancedFuel I’ll have to work on it but I haven’t been able to get it to work.

status fuel bug ?? 100 only

Nothing yet kinda sucks because this CarHud is awesome and easy to edit. Yet sucks seeing that 100 on the fuel :frowning:

to all who want to know how to add api in for the fuel here it is working with legacyfuel

line 37 change local currentFuel = 100 to local currentFuel = 0.0
line 104 add currentFuel = GetVehicleFuelLevel(vehicle)

3 Likes

I’ll try it tonight see if I can get it to work. You’re awesome thanks. :slight_smile:

thank you I’ll try :star_struck: