FiveM Entity Management: Why Your Server Has 800 Vehicles Nobody Asked For
Let me paint a picture you’ve probably seen before. It’s Friday night, your server has 80 players online, and suddenly everyone starts rubberbanding. You check resmon — nothing looks crazy. CPU is fine. So what gives?
Open your server console and run a quick entity count. If you see 600+ total entities, that’s your answer.
What Even Is an Entity?
In FiveM terms, an entity is any networked object that OneSync has to keep track of and synchronize across all connected players. That includes:
- Vehicles — every car, bike, boat, helicopter
- Peds — NPCs, shop keepers, mission peds, bodyguards
- Objects — props, placed items, drug tables, whatever
Every single one of these needs to be tracked, synchronized, and sent to every player who’s in range. The more entities you have, the more work OneSync has to do every tick.
How Entity Bloat Happens
Nobody intentionally spawns 800 vehicles. It happens gradually through scripts that create entities without properly cleaning them up.
The Usual Suspects
Car dealers and garages — Player pulls a car out of the garage, drives it somewhere, then pulls another one out. First car is still sitting there. Multiply by 80 players over a few hours.
Job scripts — Police vehicles that spawn when someone goes on duty but never despawn when they go off duty. EMS ambulances left at the hospital. Trucker trailers abandoned on the highway.
Drug scripts — Some drug scripts spawn props or peds for every processing location, whether players are nearby or not. I’ve seen drug scripts with 40+ peds spawned permanently on a server.
Race scripts — Spawn 10 cars for a race, race ends, nobody remembers to delete them.
The Math That Breaks Your Server
Let’s say your server is averaging 15 entities per player. With 60 players, that’s 900 entities. OneSync has to:
- Track the position and state of all 900 entities
- Determine which entities are relevant to each of the 60 players
- Send network updates for every relevant entity to every player
- Process ownership transfers when players move in and out of range
That’s a LOT of work happening every server tick.
What’s a Healthy Entity Count?
Based on dozens of servers I’ve worked on:
- Under 200: Great. Server will feel smooth even at high player counts.
- 200-400: Fine for most servers. Watch it during peak hours.
- 400-600: You’ll start noticing desync and occasional hitches with 50+ players.
- 600+: Your server is going to struggle no matter what.
These numbers are per-server totals, not per-player.
How to Fix It
1. Audit Your Vehicle Spawning Scripts
Every CreateVehicle call needs a corresponding DeleteEntity. Search your scripts:
-- Find every CreateVehicle that doesn't have cleanup
-- If a script creates vehicles, it MUST handle deletion
Look for garage scripts, vehicle shops, and job vehicle spawners. Make sure they:
- Delete the old vehicle when spawning a new one
- Delete vehicles when a player disconnects
- Have a maximum vehicle limit per player
2. Add a Server-Side Cleanup Script
Run something that periodically checks for abandoned entities:
-- Every 5 minutes, check for vehicles with no recent driver
-- that are far from any player
CreateThread(function()
while true do
Wait(300000) -- 5 minutes
for _, vehicle in ipairs(GetAllVehicles()) do
local driver = GetPedInVehicleSeat(vehicle, -1)
if driver == 0 then
-- No driver — check if any player is nearby
local vehCoords = GetEntityCoords(vehicle)
local nearPlayer = false
for _, playerId in ipairs(GetPlayers()) do
local ped = GetPlayerPed(playerId)
local dist = #(GetEntityCoords(ped) - vehCoords)
if dist < 100.0 then
nearPlayer = true
break
end
end
if not nearPlayer then
DeleteEntity(vehicle)
end
end
end
end
end)
Don’t make it too aggressive though — deleting a car someone just parked will annoy your players.
3. Use SetEntityAsNoLongerNeeded
If you’re creating temporary entities (NPCs for missions, props for interactions), mark them with SetEntityAsNoLongerNeeded when you’re done:
SetEntityAsNoLongerNeeded(ped)
This tells the game engine it can clean up the entity when appropriate, rather than keeping it alive forever.
4. Monitor Your Entity Counts Over Time
This is where running resmon once and calling it a day falls short. Entity counts fluctuate throughout the day based on player count and activity. You need to track them over time to see the trend.
FivePulse tracks entity counts (vehicles, peds, objects) every 30 seconds and shows you the trend on a chart alongside player count. You can see exactly when entity count spikes and correlate it with what’s happening on your server.
The OneSync Entity Lockdown Setting
If you want to prevent clients from spawning unauthorized entities entirely:
set onesync_entityLockdown strict
This makes it so only the server can create networked entities. Clients trying to spawn vehicles through modded menus will fail. It’s both a performance and a security measure.
Bottom Line
Entity bloat is sneaky because it builds up slowly. Your server feels fine at restart, then gradually degrades over hours as entities pile up. The fix isn’t complicated — it just requires making sure every script that creates entities also cleans them up.
Track it. Fix it. Your players will notice the difference immediately.
Want to find your server's problems automatically?
FivePulse scans your server and tells you exactly what's wrong — with copy-paste fixes.
Try FivePulse Free