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
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$?
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.
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 )
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).
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
I released a new version with this fixed, you should be able to place checkpoints on all the roads and airports now
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,
â 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