There are random times on my server where a player’s vehicle will just disappear while they are in it. There are times it does not happen often, but then there are others where it does happen often (maybe 15 min between disappearances?). One time I just happened to notice my car disappeared when another player left the server, but other times it happens without any (dis)connects.
In my scripts, I have each client building up a table of vehicles loaded in every ~5 seconds and then looping those vehicles and checking for certain decorators to draw text. I’m not sure if this would have some effect on this.
I have no reproducible method to this problem. I have no idea how to approach this issue, and I am unsure if anybody else has ever encountered it. Figured it might be worth a shot to make a post.
As far as I understand SetEntityAsMissionEntity function sets an entity to either always be rendered(?) in the game as it is something important or either set it not as a mission entity and let it be randomly rendered(?) (just like vehicles on the street in singleplayer).
Yeah, but the cars are disappearing while players are actually driving them. Setmissionentity stops cars from despawning when you get far away from them if they are empty.
I am assuming you are asking if the vehicle is disappearing for the person driving it – yes. It disappears for every person at the same exact time, including the occupant(s).
In my case I’ve narrowed down a pretty solid repro - which involves:
Ensure player count is at least four
Take player owned vehicle to LS Customs
Make -any- change to said vehicle (Repair/Modification)
Drive vehicle around
Wait for random deletion
This mind you is all involving Sighmir’s LS Customs module. I’ve tried manually invoking the SetEntityAsMissionEntity native in both the native form, and using Citizen.InvokeNative. This does not seem to resolve the issue at all.
It should be noted that this issue only occurs after using the customs. If the user stores the vehicle in the garage after, and spawns said vehicle again - they will not experience the issue.
I’ve also tried spooling up a new server instance with stock fivem, vrp, and Sighmir’s scripts - and still experience it. So I’m confident it is not an issue related to or cause by script conflicts.
I’m going back through the client script for LS Customs and looking for anything that would flag the vehicle as not owned, or no longer needed.
Had a sudden upsurge of vehicles being deleted - are you running any scripts that deal with vehicle related natives?
Gas Stations, Garages, LS Customs - that sort?