Controlling traffic and pedestrian density on a FiveM server
GTA V fills the world with ambient cars and pedestrians. On a busy roleplay server that can mean dozens of AI vehicles clogging roads, extra network entities and a lower frame rate — while on an empty map the city feels dead. FiveM lets you dial density to exactly what your server needs.
Short answer: Density natives such as SetVehicleDensityMultiplierThisFrame, SetPedDensityMultiplierThisFrame, SetRandomVehicleDensityMultiplierThisFrame, SetParkedVehicleDensityMultiplierThisFrame and SetScenarioPedDensityMultiplierThisFrame take a 0.0–1.0 multiplier and must be called every frame. To remove ambient population entirely with OneSync, set the onesync_population convar to false. Block specific models server-side by cancelling entityCreating.

#The density natives
local TRAFFIC = 0.4 -- moving cars
local PARKED = 0.4 -- parked cars
local PEDS = 0.5 -- walking pedestrians
CreateThread(function()
while true do
SetVehicleDensityMultiplierThisFrame(TRAFFIC)
SetRandomVehicleDensityMultiplierThisFrame(TRAFFIC)
SetParkedVehicleDensityMultiplierThisFrame(PARKED)
SetPedDensityMultiplierThisFrame(PEDS)
SetScenarioPedDensityMultiplierThisFrame(PEDS, PEDS)
Wait(0)
end
end)These natives are named “ThisFrame” for a reason: the value applies to one frame only. This is one of the few places where a permanent Wait(0) loop is correct — the cost is a handful of native calls per frame.
#Other population toggles
SetCreateRandomCops(false) -- no random police cars
SetCreateRandomCopsNotOnScenarios(false)
SetCreateRandomCopsOnScenarios(false)
SetGarbageTrucks(false) -- no ambient garbage trucks
SetRandomBoats(false) -- no ambient boatsRandom cops matter on roleplay servers: AI police cars chasing players undermine real officers. Disabling the wanted system itself is covered in disabling wanted levels and dispatch.
#Server-side control with OneSync
set onesync_population falselocal BLOCKED = {
[`police`] = true, [`police2`] = true, [`policeb`] = true,
[`rhino`] = true, [`lazer`] = true,
}
AddEventHandler('entityCreating', function(entity)
if BLOCKED[GetEntityModel(entity)] then
CancelEvent()
end
end)entityCreating fires on the server before an entity is created, so cancelling it stops the entity from existing for anyone. It is also a light anti-abuse tool for blocking military vehicles that should never appear.
#Choosing a density
| Server | Traffic | Peds | Notes |
|---|---|---|---|
| Serious RP, many players | 0.2–0.4 | 0.3–0.5 | Players create the life; AI fills gaps |
| Casual RP, few players | 0.5–0.8 | 0.6–0.9 | Keeps the city alive |
| Racing / drift | 0.0–0.2 | 0.2–0.5 | Clear roads matter more than realism |
| PvP / redzone | 0.0 | 0.0–0.2 | Every AI entity is noise |
#Performance effect
Every AI car and ped is an entity the game simulates and, with OneSync, may sync across players. Lower density means fewer entities, less network traffic and higher frame rates in dense areas. It is one of the cheapest wins in client FPS optimisation and helps against desync.
Questions
How do I remove NPC traffic in FiveM?
SetVehicleDensityMultiplierThisFrame(0.0) and SetRandomVehicleDensityMultiplierThisFrame(0.0) every frame in a client loop, or disable ambient population with set onesync_population false.Why does my density script not work?
…ThisFrame natives must be called every frame. A loop with Wait(1000) resets the density to vanilla between calls.How do I stop AI police from spawning?
SetCreateRandomCops(false) and its two scenario variants on the client, and block police models with entityCreating on the server if needed.Does lower density improve FPS?
Ready to pick a map?
Twelve themes on three base map styles, $8 each, instant download.