Vehicle Despawns

Hallo there.
First of all i know there has been plenty of topics about this in the past, but it seems to have changed.

I’ve been out of fivem for a good while, and just recently got back.
I’ve looked this over multiple times, and found topic on it, but mostly +2 years old, which doesn’t work for me anymore, atleast.

So, vehicles has always despawned when no player is near, specially with onesync in the early days.
I used to call stuff like NetworkIdCanMigrate, SetEntityAsMissionEntity etc, to keep them from despawning, but it doesn’t seem to help anymore.

So how do we keep vehicles from despawning now-o-days? Anyone got some guidance and tips on this?

Also, i might have vehicles stopped actually, not 100% sure yet, but a issue that i can replicate over and over, is trailers ( tvtrailer as an example ).

if i spawn that one, near another player, and that player leaves the area before i get there, it’s 100% of the time gone.

All tips and tricks on this topic is highly appriciated, thank you in advance.

Spawning vehicles server side is the goto nowadays. This provides persistent vehicles to a certain degree. As far as I am aware, there are still some migration issues with entity ownership that can occur and lead to despawning vehicles.

As a short explanation:
Onesync adds a culling radius around the player. All networked entities (e.g. other players and vehicles) are non-existent beyond this radius for the current player.
If you now spawn a vehicle on server side, this vehicle should stay loaded at all times, even when no player is inside that radius. So as long as no player is near it, the server retains control as long as needed until another player is ready to “take over”.

The only workaround is to keep track of those “failed migration” vehicles and respawn them when necessary.

I’ve personally developed a (paid) resource for the past years that does exactly that. Respawning when necessary and on server side.
But there have been a few other resources in the past weeks that do something similar (according to their description).

Thanks for the reply, i did read somewhere, that serversided spawn was the future, however, i also read, that client sided spawning, now should do the exact same, which is confusing me abit.
But i guess i’ll take a try at it :slight_smile: thanks!