Ir para o conteúdo principal
FiveMX
Loja
Scripts
MLOs
Servidores Completos
Mods Grátis
Ferramentas
Guias
Todos os Produtos
FiveMX

Comece a construir seu servidor hoje.

Recursos FiveM selecionados, entrega instantânea, mods grátis para começar e guias práticos em um marketplace tranquilo.

Navegar na lojasupport@fivemx.com

Loja

  • Loja
  • Todos os produtos
  • Mods grátis
  • Melhores scripts & mods
  • Scripts FiveM

Frameworks

  • Scripts QBCore
  • Scripts ESX
  • QBox
  • Standalone

Comunidade

  • Blog
  • Suporte
  • Criadores
  • Afiliados

Jurídico

  • Política de privacidade
  • Termos de serviço
  • Política de reembolso
  • Entrega digital
  • Política de cookies
  • Conformidade LGPD/GDPR
  • DMCA
  • Informações legais
  • Política editorial
© 2026 FiveMX. Todos os direitos reservados.·FiveMX não é afiliado à Rockstar Games, Take-Two Interactive ou CFX.re. Todas as marcas são propriedade de seus respectivos donos.
GitHubDiscordDocs
Table of Contents
Why Should You Reduce NPC Density?Server and Client PerformanceDesync and "Ghost Cars"Roleplay ImmersionThe Solution: Lua Native FunctionsThe Core Density FunctionsHow to Create the Density Control ScriptStep 1: Create the Folder StructureStep 2: Configure the fxmanifest.luaStep 3: Write the Client Script (client.lua)Complete Eradication (Zero NPCs)Advanced Tip: Dynamic DensityRecommended Density Presets by Server TypeExample: Dynamic Density by Player CountCommon Problems and FixesIntegration with Other ResourcesValidation Checklist Before You Ship ItConclusion

Turn framework research into a launch-ready script stack

Use this guide to narrow the framework decision, then move into the core commercial hubs for verified scripts, curated bundles, and a faster server launch path.

Framework hub

Move into the QBCore landing page to compare verified scripts, framework fit, and install-ready products built for modern FiveM servers.

Open QBCore hub

Framework hub

Use the ESX landing page to compare framework-specific resources, launch guidance, and premium products that fit ESX-first servers.

Open ESX hub

Premium catalog

Move from research into the main shop to compare real products, framework labels, screenshots, and production-ready quality signals.

Open premium shop

Disclosure: Some links below are affiliate links to FiveMX products. We may earn a commission at no extra cost to you.

Premium Scripts You Might Like

Free Scripts You Might Like

Related Articles

This guide aims to introduce readers to LUA scripting within the context of FiveM, a popular modification framework for GTA V. We will cover the essentials of L

August 29, 2024

Use FiveM resmon to find slow resources, read CPU and memory usage, compare scripts, and optimize your server without guessing.

October 9, 2024

Learn how to optimize FiveM server loading times by managing resources, using efficient mods, and choosing the right server host to eliminate annoying delays.

September 3, 2024

How to Reduce NPC Density in FiveM: Complete Guide

Published on March 12, 2024·by Lars Miller(Founder & Lead Editor)·Credentials·6 min read·Updated on May 18, 2026
Tutorials & Guideshow to reduce npc density

0.2 density

Safe RP baseline

A practical starting point for busy RP servers that still want some ambient traffic.

0.0-0.1 density

High-population fallback

Useful once player activity is high enough that AI traffic mostly causes desync and clutter.

Per frame

Update cadence

These natives must run every frame, otherwise GTA V starts repopulating the world immediately.

Grand Theft Auto V was designed as a single-player game populated by thousands of AI-controlled pedestrians and vehicles.

How to Reduce NPC Density in FiveM: Complete Guide
How to Reduce NPC Density in FiveM: Complete Guide

Grand Theft Auto V was designed as a single-player game populated by thousands of AI-controlled pedestrians and vehicles. While this creates a vibrant, living world in story mode, it can cause severe performance and synchronization issues in a multiplayer FiveM environment.

Whether you are running a 100+ player roleplay server or a high-speed racing server, learning how to reduce or completely eliminate NPC density is a important step in .

2026 update: This guide still uses the current Cfx.re native approach: density multipliers are client-side, frame-based calls. The important part is not the exact folder name, but making sure one resource owns these calls consistently and starts after any framework or utility resource that might also touch ambient traffic.

Why Should You Reduce NPC Density?

Reducing NPC Density in FiveM for Better Performance

Before diving into the code, you should understand why almost every major server alters the default AI density.

Server and Client Performance

Every NPC (Non-Player Character) requires CPU power to calculate pathfinding, AI behavior, and physics. When you multiply this by 50+ players scattered across Los Santos, the server and the players' clients struggle to keep up. Reducing NPC density is one of the fastest ways to .

Desync and "Ghost Cars"

If you have ever driven down the highway at 150mph and crashed into an invisible car, you have experienced desync. High NPC vehicle density overwhelms the network state, meaning player A sees a car that player B does not. Less AI means less data to synchronize.

Roleplay Immersion

In serious RP environments powered by , players are relied upon to populate the world. Having random AI walk into active hostage negotiations or AI cars ramming into pulled-over vehicles breaks immersion instantly.

The Solution: Lua Native Functions

To control NPC density, we use specific native functions provided by Cfx.re. Because these functions must run every single game frame to override the base game's engine, they are placed inside a client-side loop.

Frequently Asked Questions

How to Create the Density Control Script?

We will create a lightweight, standalone resource to handle this so it does not interfere with your other scripts. 1. Navigate to your server's resources folder. 2. Create a new folder named traffic_control.

What is Reduce NPC Density in FiveM?

Grand Theft Auto V was designed as a single-player game populated by thousands of AI-controlled pedestrians and vehicles. While this creates a vibrant, living world in story mode, it can cause severe performance and synchronization issues in a multiplayer FiveM environment.

What density value should I start with on a roleplay server?

For most roleplay servers, 0.2 is the safest first test because it removes most unnecessary traffic while keeping enough ambient life for quieter districts. From there, move lower only if you still see desync or unnecessary CPU load.

Can reducing NPC density break ESX or QBCore resources?

No, not by itself. Density control only changes ambient world population. Problems usually come from start order conflicts or another resource overwriting the same native calls each frame.

Table of Contents

Why Should You Reduce NPC Density?Server and Client PerformanceDesync and "Ghost Cars"Roleplay ImmersionThe Solution: Lua Native FunctionsThe Core Density FunctionsHow to Create the Density Control ScriptStep 1: Create the Folder StructureStep 2: Configure the fxmanifest.luaStep 3: Write the Client Script (client.lua)Complete Eradication (Zero NPCs)Advanced Tip: Dynamic DensityRecommended Density Presets by Server TypeExample: Dynamic Density by Player CountCommon Problems and FixesIntegration with Other ResourcesValidation Checklist Before You Ship ItConclusion

Launch faster

Compare curated bundles

Bundles shorten the path from planning to launch by grouping the highest-leverage scripts into a cleaner commercial starting point.

View bundles
Home
Blog
Tutorials & Guides
Browse QBCore-ready scripts
Review the ESX script path
Browse premium FiveM scripts
Advanced FPS Booster

Advanced FPS Booster

$5.49
Tunnel & Paleto Bay

Tunnel & Paleto Bay

$15.49
Kodak’s Hood Golden Acres

Kodak’s Hood Golden Acres

$8.49
Hampset RPC Police Station

Hampset RPC Police Station

$33.99
Highway Police Patrol MLO

Highway Police Patrol MLO

306 downloads
Bunker shadow complex ( MAP + SCRIPT )

Bunker shadow complex ( MAP + SCRIPT )

259 downloads
The Most Advanced Appearance

The Most Advanced Appearance

251 downloads
Italian Pizzeria - Vespucci Pizza [FiveM MLO]

Italian Pizzeria - Vespucci Pizza [FiveM MLO]

247 downloads
Introduction to LUA-Scripting for FiveM
Introduction to LUA-Scripting for FiveM
How to Use Resmon in FiveM (To Optimize Resources)
How to Use Resmon in FiveM (To Optimize Resources)
Eliminate Annoying Delays: Optimize FiveM Server Loading ...
Eliminate Annoying Delays: Optimize FiveM Server Loading ...
Citizen.CreateThread

The Core Density Functions

There are five primary natives you need to know:

  1. SetVehicleDensityMultiplierThisFrame(multiplier) - Controls moving traffic.
  2. SetPedDensityMultiplierThisFrame(multiplier) - Controls walking pedestrians.
  3. SetRandomVehicleDensityMultiplierThisFrame(multiplier) - Controls parked/random cars.
  4. SetParkedVehicleDensityMultiplierThisFrame(multiplier) - Controls static parked cars in lots.
  5. SetScenarioPedDensityMultiplierThisFrame(multiplier, multiplier) - Controls NPCs doing activities (smoking, drinking coffee, sitting).

The multiplier is a float value between 0.0 (completely disabled) and 1.0 (default GTA V density).

How to Create the Density Control Script

We will create a lightweight, standalone resource to handle this so it does not interfere with your other scripts.

Step 1: Create the Folder Structure

  1. Navigate to your server's resources folder.
  2. Create a new folder named traffic_control.
  3. Inside traffic_control, create two files: fxmanifest.lua and client.lua.

Step 2: Configure the fxmanifest.lua

Open fxmanifest.lua and define the resource. This tells FiveM to load your client script.

fx_version 'cerulean'
game 'gta5'

author 'FiveMX'
description 'Controls NPC and Traffic Density'
version '1.0.0'

client_script 'client.lua'

Step 3: Write the Client Script (client.lua)

Open client.lua and insert the following code. This example reduces all traffic and pedestrians to 20% of their normal volume, which is the "sweet spot" for active RP servers.

-- Set the desired density multiplier (0.0 to 1.0)
local densityMultiplier = 0.2 

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0) -- Must run every frame
        
        -- Apply the multipliers
        SetVehicleDensityMultiplierThisFrame(densityMultiplier)
        SetPedDensityMultiplierThisFrame(densityMultiplier)
        SetRandomVehicleDensityMultiplierThisFrame(densityMultiplier)
        SetParkedVehicleDensityMultiplierThisFrame(densityMultiplier)
        SetScenarioPedDensityMultiplierThisFrame(densityMultiplier, densityMultiplier)
        
        -- Optional: Disable AI emergency services
        -- This prevents AI cops/medics from responding to player crimes
        local playerPed = GetPlayerPed(-1)
        local pos = GetEntityCoords(playerPed) 
        ClearAreaOfCops(pos.x, pos.y, pos.z, 400.0)
    end
end)

Complete Eradication (Zero NPCs)

If you are running a drift server or a pure PvP arena, you likely want zero AI. Simply change local densityMultiplier = 0.2 to 0.0.

You may also want to add garbage cleanup to remove broken AI vehicles:

-- Add inside the while loop if multiplier is 0.0
SetGarbageTrucks(false)
SetRandomBoats(false)

Advanced Tip: Dynamic Density

Running a zero-wait thread (Citizen.Wait(0)) is standard for these frame-based natives, but if you want to optimize even further, you can adjust the density based on the current player count.

Many advanced servers use server-side callbacks to check how many players are online:

  • 0–30 Players: 0.8 Density (Make the city feel alive when it's quiet).
  • 30–80 Players: 0.4 Density (Balance performance).
  • 80+ Players: 0.0 Density (Players populate the city entirely, max performance).

Recommended Density Presets by Server Type

The biggest mistake is treating every server the same. A whitelisted city with 90 active civilians should not use the same density profile as a casual public freeroam server.

Server typeVehicle densityPed densityScenario pedsWhy
Serious RP / city economy0.1-0.20.1-0.20.0-0.1Leaves roads readable while preventing ghost cars and random AI interruptions.
Public RP / mixed server0.2-0.40.2-0.40.1-0.2Keeps the city from feeling empty when player count fluctuates.
Drift / racing0.0-0.10.00.0Maximum road clarity and fewer collisions at speed.
PvP / arena / event server0.00.00.0Removes all unnecessary AI noise and improves consistency.
Development / testing0.3-0.50.3-0.50.2Lets you test pathing and visuals without full story-mode density.

If you are unsure, start at 0.2 across the board, run a test event with 15-20 players, and profile the server before going lower.

Example: Dynamic Density by Player Count

This pattern keeps quiet hours immersive without punishing peak-time performance:

local function getDensityForPlayerCount(playerCount)
    if playerCount >= 80 then
        return 0.0
    end

    if playerCount >= 40 then
        return 0.2
    end

    return 0.5
end

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5000)
        LocalPlayer.state.trafficDensity = getDensityForPlayerCount(#GetActivePlayers())
    end
end)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local densityMultiplier = LocalPlayer.state.trafficDensity or 0.2
        SetVehicleDensityMultiplierThisFrame(densityMultiplier)
        SetPedDensityMultiplierThisFrame(densityMultiplier)
        SetRandomVehicleDensityMultiplierThisFrame(densityMultiplier)
        SetParkedVehicleDensityMultiplierThisFrame(densityMultiplier)
        SetScenarioPedDensityMultiplierThisFrame(densityMultiplier, densityMultiplier)
    end
end)

The exact threshold values are less important than the operating principle: more players in the city means ambient AI should get out of the way.

Common Problems and Fixes

If density changes look inconsistent, the issue is usually not FiveM itself but resource interaction:

  • Traffic returns after a few seconds: Another resource is likely calling the same natives with a higher value. Search your resource folder for SetVehicleDensityMultiplierThisFrame.
  • Only some NPCs disappear: Scenario peds or parked vehicles are still enabled, so the world feels half-cleaned. Lower all five density groups together first, then fine-tune.
  • Police keep spawning anyway: Ambient density and emergency-service cleanup are separate concerns. Use ClearAreaOfCops or disable wanted-level systems if needed.
  • World feels too empty at low population: Raise only peds and parked cars slightly before reintroducing moving traffic.

Integration with Other Resources

Ensure that your new traffic_control script is added to your server.cfg:

ensure traffic_control

If you are using reliable frameworks like QBCore or ESX, ensure this script starts after the framework to prevent base resources from overriding your native calls.

Validation Checklist Before You Ship It

Before pushing density changes to production, verify these four points:

  1. Resmon stays stable with the script running in a busy area for several minutes.
  2. Two players in the same district see the same road state instead of different ghost vehicles.
  3. Mission-critical resources like police jobs, delivery scripts, or custom traffic scripts still behave as expected.
  4. Your city does not feel unnaturally dead during low-population hours.

That last point matters. Performance wins are real, but the right target is not "zero NPCs everywhere forever." The right target is "enough ambient life to support immersion, but not enough to waste sync budget."

Conclusion

Reducing NPC density is the simplest, most effective modification you can make to improve server stability and hit registration. Whether dialing it down for performance or turning it off completely for competitive gameplay, a few lines of Lua code will drastically improve the player experience.

Looking to optimize further? Check out our guides on migrating data properly from MySQL Async to OxMySQL or explore high-performance FiveM Scripts built with optimization in mind.

More on This Topic

How to Install ReShade on FiveM: Ultimate 2026 Graphics GuideFiveM: How To Play (Full Guide)FiveM: How to Remove the Crosshair (Players & Server ...FiveM: How to Fix Texture LossHow to Install Addon Cars on FiveM: Full Guide
optimizing your FiveM server performance
boost FPS in FiveM
FiveM Frameworks
Previous Article

Best FiveM Settings to Boost FPS

Next Article

How to Install FiveM Addon Cars