[Release] StreetRaces - Multiplayer Races with Checkpoints, HUD and more [v1.00]

About

This FiveM resource implements street races with custom checkpoints, HUD and more. Quickly record checkpoints by setting map waypoints and then create a race for money!

  • Create unique races by adding and removing checkpoints on the map
  • Save and load recorded checkpoints by name
  • Custom HUD that displays time and checkpoints while racing
  • Preview race checkpoints after joining a race
  • Start countdown that freezes vehicle positions
  • Command to cancel race and refund money before it starts
  • Client and server configuration options (including disable HUD and 3D checkpoints)
  • Easily port to your framework by customizing the port_sv.lua file

Download

Demo

Commands

  • /race start amount [delay] - Start a race for money using waypoint or recorded checkpoints
    • Optional argument for delay before race starts (default 30s)
  • /race cancel - Cancel a created race before it starts and refund money
  • /race leave - Withdraw from the active race (no refunds)
  • /race record - Record checkpoints using map
    • Set waypoints on the map to create checkpoints (snaps to nearest vehicle path node)
    • Double click existing checkpoints to remove
  • /race clear - Clear recorded checkpoints
  • /race save name - Save recorded checkpoints with name
  • /race load name - Load recorded checkpoints with name
  • /race delete name - Delete recorded checkpoints with name
  • /race list - List saved checkpoints by name

Changes

  • RELEASE_V1_00
    • No changes, incremented version to full release.
  • RELEASE_V0_90
    • Added commands to save, load, list and delete recorded checkpoints
      • /race save name - Save recorded checkpoints with name
      • /race load name - Load recorded checkpoints with name
      • /race delete name - Delete recorded checkpoints with name
      • /race list - List saved checkpoints by name
    • Added new functions to port_sv.lua
      • loadPlayerData(source) - Load and return saved data for player
      • savePlayerData(source, data) - Save serialized player data
    • Fixed waypoint races to use all path nodes
  • RELEASE_V0_85
    • Changed checkpoint recording to use all path nodes
    • Fixed bug where awarded prize money was incorrect if a player leaves an active race
    • Added server configuration options
      • finishTimeout - Timeout in ms for removing a race after winner finishes (players still racing will receive a DNF notification)
      • notifyOfWinner - Notify all players of the winner (false will only notify the winner)
  • RELEASE_V0_80
    • Initial release

Files and Configuration

Known Issues

  • none

Related Resources

23 Likes

Really unique and cool script! Thanks for this. Just one question, in an ESX server will it have a functioning economy system involved with this for example, if you win a race you bet 500$ and get 1000$?

1 Like

Thanks! All the server side money and player functions have been abstracted to the port_sv.lua file where you can add your ESX or other framework code. I haven’t tested it yet but it should be fairly straight forward to get the ESX player object from source and then add and remove money.

If someone ports the port_sv.lua to ESX I can add a link to their comment in my main post.

1 Like

I dont get any Money when im done, if i win and Writing that command

Would be possible to add even already placed races?

Although this is really great one! Thank you for that. I will give you feedback later, when I will test this :slight_smile:

Do you have to be near the road? I’ve replace the airport at the top with the drag strip, can’t seem to start a race there.

“No such command race.”

Did you implement the functions in the port_sv.lua file? You need to add the code for whatever framework you are using but it shouldn’t be much (e.g. ESX already has getMoney, addMoney and removeMoney functions :wink: )

I’m not quite sure what you mean by already placed races? Eventually I’d like to add the ability to save and load recorded checkpoints so that you can record a track and then race the same track over and over.

The checkpoints actually always use the nearest vehicle node to avoid weird checkpoint placement. The downside to that is some areas like the airfield don’t have path nodes but without that you sometimes get checkpoints that aren’t on the road (or above/below).

For ESX users

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

-- Helper function for getting player money
function getMoney(source)
    local xPlayer = ESX.GetPlayerFromId(source)
    local getmoney = xPlayer.getMoney()
    return getmoney
end

-- Helper function for removing player money
function removeMoney(source, amount)
    local xPlayer = ESX.GetPlayerFromId(source)
    xPlayer.removeMoney(amount)
end

-- Helper function for adding player money
function addMoney(source, amount)
    local xPlayer = ESX.GetPlayerFromId(source)
    xPlayer.addMoney(amount)
end

9 Likes

Awesome release, only issue we found is that when creating checkpoints, it doesn’t seem to like dirt roads.

Tested with 30 players and work GREATTTT!!!. Thank you so much.!

Awesome release! tested with 12 players! In a future can you make a sistem for premade races? for maps like nürburgring spa etc…

I released a new version with this fixed, you should be able to place checkpoints on all the roads and airports now :slight_smile:

That’s great news, thank you for the feedback!

Yes, I’m working on adding a system to save and load recorded checkpoints. With addon maps like Nurburgring it’s a bit tricky since they don’t include a minimap or path notes to place checkpoints but I’'m keeping it in mind and will see what can be done.

Love this script. Perfect for all uses, only issue i’ve noticed on my server is that when you click on the map whilst recording checkpoints, it does place them, however removes them visually on the map straight away so you can’t go back and remove them etc.

Minor bug but works fine for me other wise. Works perfect for ESX using Cosmo’s code posted above.

do we just copy pasta over everything in port lua? i must be missing something, everything else is fine except it wont let me press E to start the race,

No. Dont overwrite anything that isnt changed. Keep the functions for getName and notifyPlayer as is.

I tried that during all my tests, but i keep getting this, i’m not sure why it isnt removing money. 6e244d01701f1d3864e201a786b69c88-png

Paste your code here and I’ll see what’s wrong

ESX = nil
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)

– Helper function for getting player money
function getMoney(source)
local xPlayer = ESX.GetPlayerFromId(source)
local getmoney = xPlayer.getMoney()
return getmoney
end

– Helper function for removing player money
function getMoney(source)
local xPlayer = ESX.GetPlayerFromId(source)
local getmoney = xPlayer.getMoney()
return getmoney
end

– Helper function for adding player money
function getMoney(source)
local xPlayer = ESX.GetPlayerFromId(source)
local getmoney = xPlayer.getMoney()
return getmoney
end

– Helper function for getting player name
function getName(source)
– Add framework API’s here
return GetPlayerName(source)
end

– Helper function for notifying players
function notifyPlayer(source, msg)
– Add custom notification here (use chat by default)
TriggerClientEvent(‘chatMessage’, source, “[RACE]”, {255,64,64}, msg)
end

when to do / race start 1500 10 no exposure nothing else