Racing scripts for racing fans

Edit waypoints and save them as a track. Load saved tracks. Delete saved tracks. List saved tracks. View 10 best lap times for saved tracks. Register a race using a track and wait for people to join. Start a race and view results. Use the NUI interface if you don’t like typing commands. Looking for testers to use these scripts and provide feedback, please.

CLIENT COMMANDS

Required arguments are in square brackets. Optional arguments are in parentheses.

/races - display list of available /races commands
/races edit - toggle editing track waypoints
/races clear - clear track waypoints
/races reverse - reverse order of track waypoints

For the following /races commands, [access] = {pvt, pub} where ‘pvt’ operates on a private track and ‘pub’ operates on a public track

/races load [access] [name] - load private or public track saved as [name]
/races save [access] [name] - save new private or public track as [name]
/races overwrite [access] [name] - overwrite existing private or public track saved as [name]
/races delete [access] [name] - delete private or public track saved as [name]
/races list [access] - list saved private or public tracks
/races blt [access] [name] - list 10 best lap times of private or public track saved as [name]

/races ai spawn [name] (vehicle) - spawn AI driver named [name] in (vehicle); (vehicle) defaults to ‘adder’ if not specified
/races ai delete [name] - delete an AI driver named [name]
/races ai deleteAll - delete all AI drivers
/races ai list - list AI driver names

For the following /races ai commands, [access] = {pvt, pub} where ‘pvt’ operates on a private AI group and ‘pub’ operates on a public AI group

/races ai loadGrp [access] [name] - load private or public AI group saved as [name]
/races ai saveGrp [access] [name] - save new private or public AI group as [name]
/races ai overwriteGrp [access] [name] - overwrite existing private or public AI group saved as [name]
/races ai deleteGrp [access] [name] - delete private or public AI group saved as [name]
/races ai listGrps [access] - list saved private or public AI groups

/races vl add [vehicle] - add [vehicle] to vehicle list
/races vl delete [vehicle] - delete [vehicle] from vehicle list
/races vl addClass [class] - add all vehicles of type [class] to vehicle list
/races vl deleteClass [class] - delete all vehicles of type [class] from vehicle list
/races vl addAll - add all vehicles to vehicle list
/races vl deleteAll - delete all vehicles from vehicle list
/races vl list - list all vehicles in vehicle list

For the following /races vl commands, [access] = {pvt, pub} where ‘pvt’ operates on a private vehicle list and ‘pub’ operates on a public vehicle list

/races vl loadLst [access] [name] - load private or public vehicle list saved as [name]
/races vl saveLst [access] [name] - save new private or public vehicle list as [name]
/races vl overwriteLst [access] [name] - overwrite existing private or public vehicle list saved as [name]
/races vl deleteLst [access] [name] - delete private or public vehicle list saved as [name]
/races vl listLsts [access] - list saved private or public vehicle lists

For the following /races register commands, (buy-in) defaults to 500, (laps) defaults to 1 lap, (DNF timeout) defaults to 120 seconds and (allow AI) = {yes, no} defaults to ‘no’

/races register (buy-in) (laps) (DNF timeout) (allow AI) - register your race with no vehicle restrictions
/races register (buy-in) (laps) (DNF timeout) (allow AI) rest [vehicle] - register your race restricted to [vehicle]
/races register (buy-in) (laps) (DNF timeout) (allow AI) class [class] - register your race restricted to vehicles of type [class]; if [class] is ‘-1’ then use custom vehicle list
/races register (buy-in) (laps) (DNF timeout) (allow AI) rand (class) (start) (recur) (order) - register your race changing vehicles randomly every lap; (class) defaults to any; (start) defaults to any; (recur) = {yes, no} defaults to ‘yes’; (order) = {yes, no} defaults to ‘no’

/races unregister - unregister your race
/races start (delay) - start your registered race; (delay) defaults to 30 seconds if not specified

/races leave - leave a race that you joined
/races rivals - list players in a race that you joined
/races respawn - respawn at last waypoint
/races results - view latest race results
/races spawn (vehicle) - spawn a vehicle; (vehicle) defaults to ‘adder’ if not specified
/races lvehicles (class) - list available vehicles of type (class); (class) defaults to all classes if not specified
/races speedo (unit) - change unit of speed measurement to (unit) = {imperial, metric}; otherwise toggle display of speedometer if (unit) is not specified
/races funds - view available funds
/races panel (panel) - display (panel) = {track, ai, list, register} panel; (panel) defaults to main panel if not specified

IF YOU DO NOT WANT TO TYPE CHAT COMMANDS, YOU CAN BRING UP A PANEL THAT CAN DO THE SAME TASK BY TYPING /races panel, /races panel track, /races panel ai, /races panel list OR /races panel register.

SERVER COMMANDS

Required arguments are in square brackets.

races - display list of available races commands
races list - list public tracks
races export [name] - export public track saved as [name] without best lap times to file named [name].json
races import [name] - import track file named [name].json into public tracks without best lap times
races exportwblt [name] - export public track saved as [name] with best lap times to file named [name].json
races importwblt [name] - import track file named [name].json into public tracks with best lap times

SAMPLE TRACKS

  • There are six sample tracks: ‘00’, ‘01’, ‘02’, ‘03’, ‘04’ and ‘05’ saved in the public tracks list. You can load sample track ‘00’ by typing /races load pub 00. To use the loaded track in a race, you need to register the race by typing /races register. Go to the registration waypoint of the race indicated by a purple circled star blip on the waypoint map and a purple cylinder checkpoint in the world. When prompted to join, type ‘E’ or press DPAD right to join. Wait for other people to join if you want, then type /races start.

  • There are backups of the sample tracks in the sampletracks/ folder with the extension ‘.json’. Track ‘00’ is backed up as sampletracks/00.json. If any of the sample tracks were deleted from the public list of tracks, you can restore them. Copy the deleted track from the sampletracks/ folder to the resources/races/ folder. In the server console, type races import 00 to import track ‘00’ back into the public tracks list.

QUICK GUIDE FOR RACE CREATORS

  • Type /races edit until you see the message 'Editing started'. Add at least 2 waypoints on the waypoint map or in the world by pressing ‘Enter’ on a keyboard, ‘A’ button on an Xbox controller or ‘Cross’ button on a PlayStation controller. Type /races edit again until you see the message 'Editing stopped'. Save the track if you want by typing /races save pvt mytrack. Register your race by typing /races register. At the starting waypoint of the track, a purple circled star blip will appear on the waypoint map and a purple cylinder checkpoint will appear in the world. This is the registration waypoint which all players will see. Players need to have enough funds to pay for the buy-in. Players should move towards the registration waypoint until prompted to join and type ‘E’ or press DPAD right to join. After all the players who want to join the race have joined, you can start the race by typing /races start.

QUICK GUIDE FOR RACING

  • There are four possible types of race you can join:
    1. Any vehicle can be used
    2. Restricted to a specific vehicle
    3. Restricted to a specific vehicle class
    4. Vehicles change randomly every lap

  • Look for registration waypoints which appear as purple circled star blips on the waypoint map. The label for a blip in the waypoint map will indicate the player who registered the race, the buy-in amount, the number of laps, the DNF timeout, if AI drivers are allowed and other parameters of the race. There will be corresponding purple cylinder checkpoints in the world.

  • If the race allows AI drivers to be added, the label will include ‘AI allowed’. The person who registered the race can add as many AI drivers as they like. Buy-in amounts will be set to 0.

  • If the race is restricted to a specific vehicle, the label will include ‘using [vehicle]’ where [vehicle] is the name of the restricted vehicle. You must be in that vehicle when you join the race. You can spawn the restricted vehicle by typing /races spawn [vehicle] where [vehicle] is the restricted vehicle. For example, if the label shows ‘using zentorno’, you can spawn the vehicle by typing /races spawn zentorno.

  • If the race is restricted to a specific vehicle class, the label will include ‘using [class] class vehicles’ where [class] is the vehicle class. The class number will be in parentheses. You must be in a vehicle of that class to join the race. If the class is not ‘Custom’(-1), you can list vehicles in the class by typing /races lvehicles [class] where [class] is the vehicle class number. If the class is ‘Custom’(-1), you can view which vehicles are allowed in the race by getting out of any vehicle you are in, walking into the registration waypoint on foot and trying to join the race as described later. A message in the chat window will tell you that you cannot join the race and will list which vehicles are allowed.

  • If the race changes vehicles randomly every lap, buy-in amounts will be set to 0 and the label will show one or more of the following.

    • If there are no restrictions on the vehicles used, the label will include ‘using random vehicles’.

    • If the race is restricted to a specific vehicle class, the label will include ‘using random [class] class vehicles’ where [class] is the vehicle class. The class number will be in parentheses.

    • If the label includes ‘start [vehicle]’, racers will start in the specified [vehicle].

    • If the label includes ‘recurring’, vehicles that appeared in previous laps may be used in later laps.

    • If the label includes ‘nonrecurring’, vehicles that appeared in previous laps will not be used in later laps.

    • If the label includes ‘unordered’, every racer may use a different random vehicle after the same lap number.

    • If the label includes ‘ordered’, every racer will use the same random vehicle after the same lap number.

  • To join the race, you will need to move toward the registration waypoint until prompted to join. The prompt will indicate who registered the race, if it uses an unsaved track or a publicly or privately saved track along with its saved name, the buy-in amount, the number of laps, the DNF timeout, if AI drivers are allowed and other parameters of the race. If there is a restriction on the vehicle or the vehicle class that can be used, you will need to comply with the restriction to join the race. You must have enough funds to pay for the buy-in amount. You can check how much funds you have by typing /races funds. Type ‘E’ or press DPAD right to join the race. The player who registered the race will be the one who starts the race. Once they start the race, all racer’s vehicles will be frozen until the start delay has expired and the race has officially begun. Follow the checkpoints until the finish. The results of the race will be broadcast to all racers who joined. Prize money will be distributed to all finishers. If you want to see the results again, type /races results.

SCREENSHOTS

VIDEOS

Files and instructions located here:

Player teleport resource:

25 Likes

Any Showcase (Screenshot/video) ? Looks Cool i will try it out !

1 Like

Unfortunately I don’t have video. FiveM barely runs at 14 fps along with the server running on my VERY underpowered PC. Video capture might decrease fps even more. The video wouldn’t or barely wouldn’t be watchable. I think I can get screenshots. I’ll post them later if I can.

Screenshots and Video

Registration point

Before race start

In race

In race

Near finish

Race results

Editing waypoints in waypoint map

Editing waypoints in world

Main command button panel

Edit tracks command button panel

Register races command button panel

Point-to-point race: Point-to-point race - YouTube

Multi-lap race: Multi-lap race - YouTube

Multi-lap random vehicle race: Multi-lap random vehicle race - YouTube

Multi-lap race with AI drivers: Multi-lap race with AI drivers - YouTube

1 Like

WiseGuy Fan pepeLaugh

3 Likes

Yeah, I recreated the 3 sample races from nopixel.

1 Like

Added car spawn command:

/races car (name) - spawn a car; (name) defaults to ‘adder’

Added command to list competitors in race player has joined

/races rivals - list competitors in a race that you joined

Not able to save and load races? can anyone help me on this!!asd

Can you post screen shots of any errors in your client F8 console and errors on the server console? Can you tell me what steps you took to cause the problem?

It looks like your messages are appearing on one line instead of separate lines. Does this happen for all your messages?

Added more error messages to narrow down source of errors. Latest version at link in original post.

1 Like

now it shows a error while saving with new files you uploaded, no error in console and f8Capturewqe

I found the error i need to change the name in server side (local raceDataFile = “./resources/races-main/raceData.json”) with same folder name, i didnt noticed it previously and thanks for the script :wink:

The resource contents should be in “./resources/races/”. You should rename “./resources/races-main/” to “./resources/races/”. That way, you don’t need to change the path in races_server.lua. I hope you like it!

1 Like

yep got it, thanks again for the great script :wink:

Newest commands in original post. Newest version at link in original post.

can some tell me what command should I run to save waypoint for a new race? like I run /races edit. now I’m standing on waypoint what command should I run now.
(I tried to run /races save. and error msg appears in the chat “cannot save. race need to have at least w waypoints.”)

You need to have at least two waypoints to save the race. If you are starting with no waypoints, make sure you are in editing mode: When you type ‘/races edit’ it should tell you ‘Editing started’ or ‘Editing stopped’. You want it to tell you ‘Editing started’. Go into the waypoint map and click where you want the start waypoint of your race. Then, click on where you want the finish waypoint. Those are the minimum two waypoints you need. To save those waypoints as a race, type ‘/races save myrace’ to save it as ‘myrace’. Make sure you have the latest version. It is at the link in the original post.

1 Like

Added two more sample races: ‘04’ and ‘05’.