Export: nx_racing.getRacerById

The export nx_racing.getRacerById retrieves detailed information about a racer based on their unique racing ID. This is useful for scripts or resources that need to fetch player data, such as in-game stats, avatar, or matchmaking rating (MMR), using the racer’s unique identifier rather than their server source.


Export Details

  • Export Name: nx_racing.getRacerById
  • Description: Searches for a player by their unique racer ID and returns the corresponding player details, or false if no matching player is found.

Usage

To call this export, use the following syntax:

local racer = exports.nx_racing:getRacerById(racerId)

Parameters

racerId (number)

The unique racing ID of the player you want to retrieve information for. This is the ID that is assigned to the player in the racing system, not the server source ID.


Return Value

A table containing the racer’s details or false if no player with the specified ID is found. The returned table has the following structure:

  • source (number): The server source identifier of the player.
  • id (number): The unique racing ID of 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 with the given racer ID is not found, the function returns false.


Example Usage

Fetching a Racer’s Details by ID

local racerId = 12345 -- Example racer ID
local racer = exports.nx_racing:getRacerById(racerId)
 
if racer then
    print("Racer Source:", racer.source)
    print("Racer ID:", racer.id)
    print("Name:", racer.name)
    print("Avatar URL:", racer.avatar)
    print("MMR:", racer.mmr)
else
    print("Player with ID " .. racerId .. " not found!")
end

Notes

  • Ensure that racerId corresponds to a valid racing ID in your server.