Trying to populate my ESX Server with SP style peds and traffic. Police spawn issue as well

Hey everyone, I have been putting together an ESX server that I am very happy with. A problem that I have tried to look into as much as possible before posting on here is AI police spawn issues and traffic/ped density.

***To help avoid some troubleshooting, I do not have any resources installed to manage police, traffic, or ped spawns and densities. I have also searched throughout my server files with lines such as “RemoveVehiclesFromGeneratorsInArea”. No luck, my suspicion is there is something either so simple or deeper in the ESX framework causing the “empty” feel to the server where everything feels so distant, and this may be affecting police spawns. ***

  1. From help in an earlier post, I have learned how to modify all my resources that involve crime to trigger wanted levels for players. My issue here is that it’s a gamble on whether the AI cops will actually be able to spawn.
    To be more specific, as soon as the wanted lights flash on the player’s radar, if police blips are present, all works fine. If the blips do not appear immediately, then no further attempts to spawn police happen or they simply are failing, and the wanted level is lost.

  2. Traffic and peds are very lacking. You spawn into a very empty server, I am not concerned with performance or sync currently. It seems like there is a radius around the player where nothing will spawn, the highway fails to populate more than a few cars, streets are empty for the most part, est…

What I would like is a server NPC population as close to the single-player experience. Or at the minimum, the population levels of a vanilla freeroam fivem server. I do have suspicious as stated above that ESX is causing this by default, but despite all the research and detailed searching I do both online and on my server files, I am hoping someone who is an ESX veteran can give me suggestions on what to do.

  1. Things I have tried are resources such as TrafficAdjuster, looking through all my resource configs for anything, searching with file contents checked on file explorer, and trying my best to find similar topics online. Hopefully, I have done as much due diligence as possible. I do not want to come across as a lazy noob lol. If you have any knowledge on these two issues above, please let me know what has worked for you.

Thank you and appreciate your time!

Hi! First of all, RemoveVehiclesFromGeneratorsInArea has something to do with the map so I don’t think that will work for changing vehicle density. So there are couple of natives that can be used to change peds on scenarios, walking, standing etc.
I’m using this code block in my server to stop NPC spawns.

while true do
        Citizen.Wait(0) -- Prevent crashing.
		SetCreateRandomCops(false)
		SetCreateRandomCopsNotOnScenarios(false)
		SetCreateRandomCopsOnScenarios(false)
		SetGarbageTrucks(false)
		SetRandomBoats(false)
       	SetVehicleDensityMultiplierThisFrame(0.0)
       	SetPedDensityMultiplierThisFrame(0.0)
		SetRandomVehicleDensityMultiplierThisFrame(0.0)
		SetScenarioPedDensityMultiplierThisFrame(0.0, 0.0)
		SetParkedVehicleDensityMultiplierThisFrame(0.0)
end

If you look further in this code block you can see there are multiple choices you can decide to whether have or not NPCs. My first suggestion for you to look for any of these natives in your server files. If any of these don’t appear in your code, you can write a small client-side script that can turn these on I think. But beware, if you are using OneSync, you will probably have sync issues.

1 Like

the cops in my server disappear after my wanted status is gone

I’m not sure if there is any difference between the scenario cops (these are the cops that stand still in front of police stations or eating donut etc.), the not scenario cops (these should be the ones you will see in traffic) and the ones that spawns because your wanted level. I’ve never worked with wanted level mechanic in FiveM so I’m not sure what can be the problem. Maybe there is a game event that is triggered when your wanted status is gone. I’ll look for natives and events and reply if I find anything.

1 Like

If you are using a roleplay framework it is possible it uses one of these natives at any point:

  • ClearPlayerWantedLevel
  • SetPlayerWantedLevel

These natives can be used both in client and server, so open your resources in a code editor like Visual Studio Code and search for these natives.

1 Like

wow i wish i knew about this way back i found
ClearPlayerWantedLevel(PlayerId()) in spawn manger and es extended

im using ESX btw

When I used FXServer without a framework I was able to play with game cops on, if I recall correct. Maybe in es_extended somehow it clears all those police peds after the player evades wanted level with IsPlayerEvadingWantedLevel() native (Note that this is a server-side only native). Never searched how can I enable GTA police before though, if I find how that works in es_extended I will add some more information to the topic.

1 Like

i found this in spawn manager but what do i change it too if i want my server like normal gta do i just delete the lines ?

– gamelogic-style cleanup stuff
ClearPedTasksImmediately(ped)
–SetEntityHealth(ped, 300) – TODO: allow configuration of this?
RemoveAllPedWeapons(ped) – TODO: make configurable (V behavior?)
ClearPlayerWantedLevel(PlayerId())

Also found this in es extended

– disable wanted level
if not Config.EnableWantedLevel then
ClearPlayerWantedLevel(PlayerId())
SetMaxWantedLevel(0)
end

i notice peds dont shoot they try to fight no matter what they dont even shoot at each other anymore maybe that second line fixes that ?

I think both of these code blocks are executed when Player ped is spawned to the world. Someone said in forums that changing Config.EnableWantedLevel = true in es_extended config fixes this issue but I’m not sure %100.