Traffic

Hi. someone who knows how to reduce mpc cars and people

1 Like

Moved, this is not a FiveM feature request.

You can create your own script that uses these natives:

http://runtime.fivem.net/doc/reference.html#_0x245A6883D966D537

http://runtime.fivem.net/doc/reference.html#_0x95E3D6257B166CF2

Or you can look for resources like ACL or vBasic or whatever that allows you to set ped/traffic density.

2 Likes
DensityMultiplier = 0.15
Citizen.CreateThread(function()
	while true do
	    Citizen.Wait(0)
	    SetVehicleDensityMultiplierThisFrame(DensityMultiplier)
	    SetPedDensityMultiplierThisFrame(DensityMultiplier)
	    SetRandomVehicleDensityMultiplierThisFrame(DensityMultiplier)
	    SetParkedVehicleDensityMultiplierThisFrame(DensityMultiplier)
	    SetScenarioPedDensityMultiplierThisFrame(DensityMultiplier, DensityMultiplier)
	end
end)

you can manipulate the DensityMultiplier variable anywhere from 0.0 to 1.0

9 Likes

Where should I put this code

Anywhere client side.

1 Like

asfasfasdsafsa

1 Like

Your best bet is to play with it to find your sweet spot.

0.0 means no cars/people, 1.0 means normal. Apart from Parked which is set to 0.5 in multiplayer usually, I think.

1 Like

can it be used to increase density over 1.0 ?

Looking for a way to increase over default value

I’d like to know the same thing. putting it to 2.0 doesnt do anything.

this is not possible. The native supports values between 0.0 and 1.0. That’s just how GTA works. Even in singleplayer you can’t boost the setting in the pause menu > 100%.

1 Like

too bad there ain’t no way to multiply the density… oh well, thanks for the reply

1 Like

What’s mean “anywhere client side”? I want to know cuz I’m not scripter but I really wants to reduce it.

For beginners I’d recommend you create a standalone resource so you can easily disable later if needed. If you’re advanced and creating a framework or complex resource you can add related code to existing client or server files you’re already using as needed.

  • Create a new folder in your servers resources folder called WhateverUniqueNameYouWant
  • Inside that folder create a file named WhateverNameYouWant.lua (usually people use client.lua for basic resource but entirely up to you)
  • Inside that file write your client side code or paste it from above in your case, save and close.
  • Create a new file called __resource.lua in your WhateverUniqueNameYouWant resource folder
  • Inside that file define the manifest version and any files that you want loaded for your resource like below. In this case you don’t need any server files, only a client side file but I left the server_scripts in there for you because you can add a file at any point that needs to run from server side, same process, separate file.
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'

server_scripts {}
client_scripts {"WhateverNameYouWant.lua"}
  • Open your server.cfg file and add a line to start the resource (Same name of the folder you created in resources folder on your server)
start WhateverUniqueNameYouWant
  • You now have a resource that you can build off of.
5 Likes

That what I was looking for. Thank you sir very much! :slight_smile:

hello or good evening i have a problem when i but and i make it start it makes me an errore how can i make it so that its walking

its not working for me says it cant load resource noai

1 Like

Thanks guys pretty easy to follow

where do i find this to edit it

i’m trying to add them to my server we dont have any