Export: nx_racing.getOngoingRaceData
The export nx_racing.getOngoingRaceData retrieves detailed information about a specific race currently in progress. This is ideal for scripts or resources needing access to race-specific data, including track information, players, and race configuration.
Export Details
- Export Name:
nx_racing.getOngoingRaceData - Description: Returns a table containing detailed information about a specified race or
falseif the race is not active.
Usage
To call this export, use the following syntax:
local raceData = exports.nx_racing:getOngoingRaceData(raceId)Parameters
raceId (number)
The unique identifier for the race. This ID is typically obtained from the list of active races or an event.
Return Value
A table containing detailed information about the race, or false if the race does not exist or is not ongoing. The returned table has the following structure:
status(number): The raceโs current status.createdTime(number): Timestamp of when the race was created.raceType(string): The type of the race (e.g., time trial, circuit).moneyPrize(number): The prize money for the race.trackId(number): The unique identifier of the track.trackName(string): The name of the track.trackType(string): The type of the track (e.g., road, dirt).trackLaps(number): The number of laps for the race.track(table): A table containing track-specific data.phasingOn(boolean): Indicates whether phasing is enabled.phasingTime(number): The duration of phasing in seconds.checkpoints(table): A table containing the raceโs checkpoints.players(table): A table containing data about players in the race.playerList(table): A list of players participating in the race.buyIn(number): The buy-in cost for entering the race.camera(boolean): Indicates whether a camera is enabled for this race.class(number): The vehicle class allowed in the race.totalRaceDistance(number): The total distance of the race in meters.
Example Usage
Fetching Data for a Specific Race
local raceId = 123 -- Example race ID
local raceData = exports.nx_racing:getOngoingRaceData(raceId)
if raceData then
print("Race Status:", raceData.status)
print("Track Name:", raceData.trackName)
print("Number of Players:", #raceData.players)
print("Total Distance:", raceData.totalRaceDistance .. " meters")
else
print("Race not found or not active.")
endNotes
- The
raceIdmust correspond to a valid ongoing race in theactiveRacestable. - This export is designed to provide comprehensive race details, making it suitable for leaderboard updates, race monitoring, or enhanced spectator features.