nx_racing:server:raceFinished Event Listener Guide
The nx_racing:server:raceFinished
event is a server-to-server event that provides race details once a race concludes. Use this event to manage race results, distribute rewards, or log data.
⚠️
The nx_racing:server:raceFinished
event is internal to the racing system and should NEVER be triggered by other scripts.
Event Listener Setup
To capture this event in your server script, add the following event handler:
AddEventHandler('nx_racing:server:raceFinished', function(raceData)
-- Event handler logic here, using `raceData` fields.
end)
Event Data Structure
The raceData
object contains the following fields:
raceId
(integer): Unique identifier for the race.raceType
(string): Type of race, either"ranked"
or"unranked"
.trackId
(integer): Unique identifier for the track.trackName
(string): Name of the track.trackType
(string): Track type, either"circuit"
or"sprint"
.trackLaps
(integer): Number of laps (relevant for"circuit"
races).racerCount
(integer): Total number of participants.racers
(array): Array of all racers with detailed information on each player’s performance.
Racers Array Structure
Each entry in the racers
array includes:
source
(integer): Player’s source ID.racer
(integer): Unique identifier for the player.racerName
(string): Display name of the player.time
(integer): Completion time in milliseconds, ornil
if the player did not finish.class
(string): Vehicle class.vehicle
(string): Vehicle model name.pos
(integer): Final race position.dnf
(boolean): Indicates if the player did not finish.
This structure enables efficient handling of race data, allowing integration with custom post-race actions.