GTA fills the streets with NPCs (peds) and traffic, and sends police after you when you commit a crime. On a roleplay server you usually want fewer NPCs and no AI police, because your own police players handle that. You control both with density multipliers from 0.0 (none) to 1.0 (normal GTA Online) and by switching off the dispatch services and the wanted level. Most frameworks already have a setting for this; without a framework, a small script does the job.
Good to know: density is decided by the game of each player, so it is always a client script that sets it every frame. The one exception is the server setting onesync_population, which switches off all NPCs at once (see below).
Set it in one place. ESX, qb-smallresources and qbx_density all set the density every frame. Add a second script that does the same and they fight over it. Choose one.
ESX Legacy
ESX has it in resources/[core]/es_extended/shared/config/adjustments.lua. Open the file through Files in the game panel:
Config.DisableDispatchServices = true -- Disable Dispatch services
Config.DisableScenarios = true -- Disable Scenarios
Config.EnableWantedLevel = false -- Use Normal GTA wanted Level?
Config.Multipliers = {
pedDensity = 1.0,
scenarioPedDensityInterior = 0.0,
scenarioPedDensityExterior = 1.0,
ambientVehicleRange = 1.0,
parkedVehicleDensity = 1.0,
randomVehicleDensity = 1.0,
vehicleDensity = 1.0
}
AI police and the wanted level are already off by default. For less traffic, lower vehicleDensity, randomVehicleDensity and parkedVehicleDensity, for example to 0.5, and pedDensity for fewer people on the street. Save and restart your server. An ESX update overwrites this file, so check your values again after updating.
QBCore (qb-smallresources)
With QBCore it's in resources/[qb]/qb-smallresources/config.lua:
Config.AIResponse = {
wantedLevels = false, -- if true, you will recieve wanted levels
dispatchServices = { -- AI dispatch services
[1] = false, -- Police Vehicles
[2] = false, -- Police Helicopters
...
}
}
Config.Density = {
parked = 0.8,
vehicle = 0.8,
multiplier = 0.8,
peds = 0.8,
scenario = 0.8
}
multiplier is the random traffic, scenario the NPCs that do something, such as sitting on a bench. Wanted levels and AI dispatch are already off. Restart your server after a change.
Qbox
The wanted level and AI dispatch are in resources/[qbx]/qbx_smallresources/qbx_disableservices/config.lua: maxWantedLevel = 0 and a list enabledServices in which everything is off by default, except police roadblocks ([8] = true). Set that one to false too if you don't want any.
The Qbox recipe has no density script. For that, Qbox makes qbx_density:
- Download it from GitHub with Code and Download ZIP.
- Upload the zip in resources/[qbx] with Upload, click the three dots ..., choose Unarchive and delete the .zip file.
- Rename the folder
qbx_density-maintoqbx_density.ensure [qbx]in the recipe's server.cfg starts it. - Set the values in
qbx_density/config/client.lua(parked,vehicle,randomvehicles,pedsandscenario, 0.8 by default) and restart your server.
qbx_density also makes gang NPCs and police less aggressive towards players, and removes some parked cars with car generator files.
Without a framework (or with vMenu): a small script
- In Files, go to resources and create a folder
npc-controlwith Create Directory. - On your PC, create the two files below and upload them into that folder with Upload.
- Put
ensure npc-controlin your server.cfg with the server.cfg editor (Manual Edit, then Save) and restart your server.
fxmanifest.lua:
fx_version 'cerulean'
game 'gta5'
client_script 'client.lua'
client.lua:
local density = 0.3 -- 0.0 = no NPCs, 1.0 = normal GTA Online
CreateThread(function()
-- no AI police, fire brigade or ambulances, and no wanted level
for i = 1, 15 do
EnableDispatchService(i, false)
end
SetMaxWantedLevel(0)
SetCreateRandomCops(false)
SetCreateRandomCopsNotOnScenarios(false)
SetCreateRandomCopsOnScenarios(false)
-- the density has to be set again every frame
while true do
SetPedDensityMultiplierThisFrame(density)
SetScenarioPedDensityMultiplierThisFrame(density, density)
SetVehicleDensityMultiplierThisFrame(density)
SetRandomVehicleDensityMultiplierThisFrame(density)
SetParkedVehicleDensityMultiplierThisFrame(density)
Wait(0)
end
end)
Change 0.3 to the value you want. What the five multipliers do:
- Ped: people walking on the street.
- Scenario: NPCs doing something, such as sitting, smoking or fishing (indoors and outdoors).
- Vehicle and Random vehicle: driving traffic.
- Parked vehicle: parked cars.
New to scripting? See your first FiveM script in Lua and Install scripts and edit your server.cfg.
No NPCs at all
For a race, drift or PvP server without any traffic, add this line to your server.cfg and restart:
set onesync_population false
According to the FiveM documentation this setting (default true) enables the spawning of NPCs. With false, no NPCs or traffic appear at all. It works with OneSync, which txAdmin turns on by default.
No server yet? With our FiveM server hosting you run ESX, QBCore or Qbox from €5 a month, and you can try one free for 24 hours.
Common problems
- Still lots of traffic after lowering it: another script also sets the density, for example ESX's own setting next to your own script. Keep one.
- Police still chases you: a script sets the wanted level back. In qb-smallresources,
wantedLevels = truegives a maximum of 5 stars. Check every script with a wanted level setting. - Parked police cars at the police stations: those come from scenarios and car generators. ESX switches the scenarios off with
Config.DisableScenarios = true. Qbox does it inqbx_smallresources/qbx_ignore/config.luaand QBCore inConfig.BlacklistedScenariosof qb-smallresources. - Nothing changes: you edited a file of a script that doesn't run, or forgot the restart. Players may have to reconnect.
Fewer NPCs also means less for your server to sync. More on performance in Optimise for 64 players or more and Find lag with resmon and the profiler. Weather and time are in Weather and time on FiveM.