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
Demo
https://gfycat.com/DownrightFlakyClingfish
Credit
Cleaned up and optimized code snippets from the following FiveM users
Related Resources
52 Likes
ArjanL
April 30, 2019, 10:29am
3
How would I modify it with an API call to another script?
4 Likes
Synch
May 2, 2019, 8:43pm
4
@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
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
ArjanL
May 3, 2019, 11:30am
10
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.
Desktop 2019.05.05 - 11.36.50.02.DVR Trim GIF by
anonymous
Doop
May 6, 2019, 9:36pm
12
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.
Doop
May 7, 2019, 2:02am
15
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
Doop
May 7, 2019, 6:31pm
17
Nothing yet kinda sucks because this CarHud is awesome and easy to edit. Yet sucks seeing that 100 on the fuel
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
Doop
May 8, 2019, 10:08am
19
I’ll try it tonight see if I can get it to work. You’re awesome thanks.