Export: nx_racing.getRacer
The export nx_racing.getRacer
retrieves detailed information about a racer based on their server source. This is ideal for scripts or resources that need to fetch player-specific racing data, such as their ID, name, avatar, or MMR.
Export Details
- Export Name:
nx_racing.getRacer
- Description: Returns a table containing information about the specified racer, or
false
if the player could not be found.
Usage
To call this export, use the following syntax:
local racer = exports.nx_racing:getRacer(source)
Parameters
source
(number)
The server-side identifier of the player. This is typically obtained from an event or server function.
Return Value
A table containing racer information or false
if the player is not found. The returned table has the following structure:
id
(number): The unique identifier for the player.name
(string): The display name of the player.avatar
(string): URL of the player’s avatar.mmr
(number): The player’s Matchmaking Rating (MMR), used for ranked races.
If the player is not found, the function returns false
.
Example Usage
Fetching a Racer’s Details
local source = 1 -- Example player source ID
local racer = exports.nx_racing:getRacer(source)
if racer then
print("Racer ID:", racer.id)
print("Name:", racer.name)
print("Avatar URL:", racer.avatar)
print("MMR:", racer.mmr)
else
print("Player not found!")
end
Notes
- Ensure the
source
parameter corresponds to a valid server-side player ID.