Framework Integration
This section guides you through the steps to integrate the HUD script with your framework, utilizing built-in functions for seamless integration.
Last updated
This section guides you through the steps to integrate the HUD script with your framework, utilizing built-in functions for seamless integration.
Last updated
You can find all the functions .
You can write whatever you want inside the functions/
folder, which contains server.lua
and client.lua
for both server-side and client-side configurations. The server.lua
file is optional because not everyone will need it. By default, everything is set up for the ESX framework and uses legacyfuel for the vehicle fuel system. As mentioned, you can customize this setup as needed to fit your server.
At the top of the client.lua
file, you need to define a global PlayerData
object. This object is intended for storing variables about the player. It must include a seatbelt
variable; otherwise, the vehicle HUD will break. You can add other variables to the object as needed.
Even if you're not using the PlayerData
object to store data, you must still define it with the seatbelt
variable. DO NOT REMOVE IT.
In my case I'm also storing player's ID in it.
You need to decide when to initialize the HUD using . In most cases, the HUD should be initialized when the player loads, but your framework might not have a playerLoaded
event. If that's the case, you can initialize the HUD a few seconds after the script loads.
You need to implement a function to retrieve fuel from your chosen fuel system. This function must be named exactly as specified. If you're not using a fuel system, simply add return 0
to the function to prevent breaking the vehicle HUD.
Each status inside the update object must be sent in the format:['status_name_you_defined_in_config'] = status_percentage
Each info inside the update object must be sent in the format:
['info_name_you_defined_in_config'] = "info_value"
functions/client.lua
Update thread:
Starting info update thread and setting player ID:
functions/server.lua
Create callback function to get server players count.
To make the vehicle HUD seatbelt indicator work, you need to inform the HUD when the seatbelt is on or off. This is a straightforward task: simply update the PlayerData.seatbelt
variable to reflect the current seatbelt state. In my example, an event is sent from the seatbelt script whenever the seatbelt state changes. Your seatbelt system might already have this event, but under different name, or you may need to create it yourself.
If you need to create the event to send these changes, simply locate the function or variable setter in your seatbelt script and send the event listed below with the current seatbelt state.
Final version of the configuration should look something like this:
functions/client.lua
functions/server.lua
To ensure the status indicators work correctly, you must update them using . You have the option to listen to your status system's status update ticker or create an infinite thread to fetch player statuses at intervals of your choice (e.g., every 1, 2, 3, or 4 seconds). The frequency of updates can be tailored to your specific needs.
This section is optional and only necessary if you have dynamic data in your info HUD (data that changes). If you're using the info HUD and have set the data with default fields that don't need to be updated, you can skip this step. The info HUD uses the to update its values. You can use this function in a thread or update it as needed. In the example case, we have a player ID, which is a static variable that doesn't need updating and should be set when the player loads. Another variable is the server player count, which changes over time, so we use a thread to keep track of the current number of players.