Perimeter script for vehicles?

Good Morning. I’m seeking some help or advise on a small issue im running into. We had a Ymap created for our QBcore server. The ymap is great and all, but we had a minor issue with cars crashing into some of entrances of the ymap. We were able to adjust some pathways for the civilians and vehicles to avoid the crashing which has worked for the most part, but we are still have maybe 2 or 3 vehicles that will spawn around the area causing that annoying “car crash sound” glitching with a building.

Is there anyone that can knows, has, or can make a “code or a script” to place a perimeter within the Ymap zone in order to just “not spawn” vehicles at all? Any informartion would help us tremendously. Thanks in advance.

Hello,

The first thing that comes to mind is to disable NPC and vehicle spawning when a player gets close to certain locations, so essentially you could utilise the following code

SetVehicleDensityMultiplierThisFrame(0.0)
SetPedDensityMultiplierThisFrame(0.0)
SetRandomVehicleDensityMultiplierThisFrame(0.0)
SetParkedVehicleDensityMultiplierThisFrame(0.0)
SetScenarioPedDensityMultiplierThisFrame(0.0, 0.0)

With that being said, I do have to mention that it’s not the ideal way of achieving what you’re attempting to fix as the snippet above will stop NPCs and vehicles spawning completely whilst they’re near your map.

If I come across a better way of achieving it (such as using a native to force NPCs and vehicles not to spawn near a coord) I will update this response.

1 Like

Thank you so much!! We did try a “native code” at first but it didnt work. I think QBcore has this snippet but if we put it a 0 it will most likely make the whole population in the city dissapear I think. Im looking to just take it out within the ymap area which is like 2 blocks. But ill give thisca try! Thanks for reaching out.