Racing in FiveM has unique technical challenges. At 200km/h, every millisecond of desync matters. A jitter that's invisible during RP becomes unplayable during a close race. Here's how to build a racing experience that feels smooth.
Understanding Racing Desync
FiveM synchronizes vehicle positions across players at regular intervals. Between updates, client-side prediction estimates where each vehicle should be. When the next update arrives and the prediction was wrong, the vehicle "snaps" to the correct position.
This snap is the jitter. At low speeds, it's barely noticeable. At high speeds, it causes cars to teleport short distances, make impossible turns, or phase through barriers.
Server Configuration for Racing
OneSync Settings
OneSync is essential for racing. Enable it and configure for low latency:
set onesync on
set onesync_population true
Network Settings
sv_maxClients 32
set rateLimiter_stateBag 150
set sv_filterRequestControl 4
Lower client counts improve sync quality. A 32-player racing server with good sync beats a 64-player server with constant jitter.
Server Tickrate
The default FiveM tickrate is 20Hz (50ms between updates). For racing, this isn't enough.
Some racing resources implement their own higher-frequency position sync:
-- Custom high-frequency vehicle sync
CreateThread(function()
while true do
Wait(16) -- ~60Hz update rate
local vehicle = GetVehiclePedIsIn(PlayerPedId())
if vehicle ~= 0 then
local pos = GetEntityCoords(vehicle)
local vel = GetEntityVelocity(vehicle)
TriggerServerEvent('race:syncPosition', pos, vel)
end
end
end)
Handling File Tweaks
GTA V's default vehicle handling is designed for open-world gameplay, not competitive racing. Adjust handling for better racing feel:
Key Handling Parameters
| Parameter | Default Effect | Racing Adjustment | |-----------|---------------|-------------------| | fInitialDriveForce | Acceleration | Increase for faster starts | | fBrakeForce | Braking power | Increase for shorter stopping | | fTractionCurveMax | Grip at speed | Increase for less sliding | | fAntiRollBarForce | Body roll | Increase for less lean in turns | | fSteeringLock | Max steering angle | Reduce at high speed for stability |
Create custom handling files per vehicle class for balanced competition.
Checkpoint and Leaderboard System
Race Script
A racing resource needs:
- Checkpoint creation and detection
- Lap timing (millisecond precision)
- Position tracking (1st, 2nd, 3rd...)
- DNF (Did Not Finish) timer
- Ghost mode option (cars pass through each other)
Leaderboard
Store best lap times in the database:
CREATE TABLE race_leaderboards (
id INT AUTO_INCREMENT PRIMARY KEY,
track_name VARCHAR(64),
player_identifier VARCHAR(64),
player_name VARCHAR(64),
lap_time INT,
vehicle_model VARCHAR(32),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_track_time (track_name, lap_time)
);
Display leaderboards on the race start line or via a /leaderboard command. Competitive players obsess over lap times and will grind for top positions.
Ghost Mode
The cleanest solution for desync during races: ghost mode. Players see other racers but can't collide with them. Each player races against the track, not against physics glitches.
-- Enable ghost mode during race
SetEntityNoCollisionEntity(playerVehicle, otherVehicle, true)
Some servers use ghost mode only for the first corner (where most crashes happen) and enable collisions afterward for more exciting racing.
Hardware Impact
Racing is CPU-sensitive because position calculations happen at high frequency. The Ryzen 9 7950X3D processes these calculations faster than any other available processor, giving you the smoothest possible sync at high vehicle speeds.
NVMe SSD matters less for racing than for RP (no database queries during races), but consistent CPU performance is essential. Any CPU throttling during a race creates visible jitter for every participant.
