Export: nx_racing.getRacerByIdentifier
The export nx_racing.getRacerByIdentifier
retrieves detailed information about a racer based on their framework-based identifier. This is useful for scripts or resources that need to fetch player-specific data from the database, such as their name, avatar, or matchmaking rating (MMR), based on the identifier used within the FiveM framework.
Export Details
- Export Name:
nx_racing.getRacerByIdentifier
- Description: Returns a table with information about a racer identified by their framework-based identifier, or
false
if no racer is found.
Usage
To call this export, use the following syntax:
local racer = exports.nx_racing:getRacerByIdentifier(identifier)
Parameters
identifier
(string)
The framework-based identifier of the racer, typically used to uniquely identify a player within the server or across sessions. This identifier is often seen in the bridge or as part of the player data in the system.
Return Value
A table containing the racer’s information or false
if no racer is found. The returned table has the following structure:
id
(number): The unique identifier of the racer.name
(string): The display name of the racer.avatar
(string): URL to the racer’s avatar image.mmr
(number): The racer’s Matchmaking Rating (MMR), used for ranked races.
If no racer is found with the given identifier, the function returns false
.
Example Usage
Fetching a Racer’s Details by Identifier
local identifier = "player_123" -- Example identifier
local racer = exports.nx_racing:getRacerByIdentifier(identifier)
if racer then
print("Racer ID:", racer.id)
print("Name:", racer.name)
print("Avatar URL:", racer.avatar)
print("MMR:", racer.mmr)
else
print("Racer not found!")
end
Notes
- Ensure the
identifier
corresponds to the correct framework-based identifier of the player, as used in the system. - The query uses
MySQL.single.await
, so the MySQL query should be efficient and optimized for performance. - If no racer matches the provided identifier, the function returns
false
, allowing you to handle such cases gracefully.