The export nx_racing.createRace
allows for the creation of races within the Nexure Racing System. This export is ideal for scripts or resources that require dynamic race setups using flexible parameters.
Export Details
- Export Name:
nx_racing.createRace
- Description: Creates and starts a race with customizable parameters, such as track selection, laps, start time, and more.
Usage
To call this export, use the following syntax:
exports.nx_racing:createRace(data)
Parameters
data
(RaceData)
A table containing the race configuration. The structure of RaceData
is as follows:
-
track
(TrackParam)random
(boolean): Iftrue
, selects a random track.verified
(boolean): For random tracks, specifies whether only verified tracks should be considered.trackId
(number): The specific track ID to use (ifrandom
isfalse
).
-
laps
(number): Number of laps in the race. -
startTime
(number): Time in milliseconds until the race starts. -
phasingOn
(boolean): Enables or disables phasing (collision immunity). -
phasingTime
(number): Duration of phasing in milliseconds (only applicable ifphasingOn
istrue
). -
buyIn
(number): The buy-in amount for the race. Set to0
for no buy-in. -
camera
(string): Camera type during the race:"unset"
: Player decides the camera view."first"
: Forces first-person view.
-
class
(number): Vehicle class index:0
for all vehicle classes.- Other values correspond to indexes in
Config.vehicleClasses.classes
.
-
moneyPrize
(number): Monetary prize for the race. Must be0
for unranked races. -
raceType
(string): Type of race:"ranked"
: Includes MMR calculations and allows monetary prizes."unranked"
: Does not affect MMR and should havemoneyPrize
set to0
.
Example Scenarios
Random Verified Ranked Race
exports.nx_racing:createRace({
track = { random = true, verified = true },
laps = 5,
startTime = 10000, -- Starts in 10 seconds
phasingOn = true,
phasingTime = 15000, -- 15 seconds of phasing
buyIn = 500, -- $500 buy-in
camera = "unset",
class = 0, -- All vehicle classes allowed
moneyPrize = 10000, -- $10,000 prize pool
raceType = "ranked"
})
Unranked Race with Specific Track
exports.nx_racing:createRace({
track = { random = false, trackId = 12 },
laps = 3,
startTime = 5000, -- Starts in 5 seconds
phasingOn = false,
phasingTime = 0,
buyIn = 0, -- No buy-in
camera = "first", -- Force first-person view
class = 1, -- Specific vehicle class
moneyPrize = 0, -- No prize for unranked
raceType = "unranked"
})