Player Vehicles Randomly Despawning

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.

3 Likes

I had this same problem while using LockSystem, still have no idea what the cause is exactly.

Hmm… have you added/removed the resource and are sure it was the resource causing it?

I could check the code for it and look for similarities with it and mine and maybe try to narrow down the cause.

Yes, as soon as it was added I had the problem, stopped as soon as it was removed. Not sure if another resource could be conflicting though.

I just looked at the code for LockSystem, and I can’t find any clear similarities between it and mine.

Do you remember how often (roughly) it would do it for you/other players? About how many other players online would it do it, if any?

It was random, every 10 minutes to an hour between the deletion of vehicles. 1-30 people online.

My guess is that It has something to do with this part:

RegisterNetEvent("ls:createMissionEntity")
AddEventHandler("ls:createMissionEntity", function(vehicleId)

	SetEntityAsMissionEntity(vehicleId, true, true)
end)

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.

On the clients themselves as well?

I am also experiencing the same problem, however, it has decreased in the amount of times that it is happening. Still an issue though.

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).

I’ve battling a similar issue - I’d be really interested to know if you made any headway

I wish I could say I have, but unfortunately nothing.

1 Like

Well, if -I- find anything I’ll reply here.

1 Like

@Briglair

Nothing much just yet - aside from:

In my case I’ve narrowed down a pretty solid repro - which involves:

  1. Ensure player count is at least four
  2. Take player owned vehicle to LS Customs
  3. Make -any- change to said vehicle (Repair/Modification)
  4. Drive vehicle around
  5. 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.

I don’t use LS Customs. I also believe I had the issue with only 2 players in the server, but never when I was alone (if I remember correctly).

Can you link the resource, as I’m unfamiliar with it. I’ll see if I can check with similarities :thinking:

@Briglair

Here you go:

https://github.com/Sighmir/vrp_lscustoms

Edit: There is a 3 way cross dependency - if you intend on firing up a test. vrp_garages and vrp_showroom are both in his repo listings.

@Briglair

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?

Nothing like that, just my own scripts. They only deal with decorators, adding/removing extras, and setting as mission entity.

SetEntityAsMissionEntity( car, true, true )

if its a player vehicle it wont disappear