Player Vehicles Randomly Despawning

Not the same thing

oh forgot to say also remove Remove SetEntityAsNoLongerNeeded. Thats the code that gets rid of the vehicles

Again, not the same thing, nor is that in the code.

i was just stating what causes the car to disappear thats all man.

I understand that, but this is a completely different issue where cars disappear when people are driving them – not when you get far away.

well to be honest ive never had a car disappearing on my while driving it. So in that case im not too sure what causes it. Maybe an addon script

Someone else having same issue with lock system. [Release] LockSystem 3.1 (Updated the 07/16/2018) [BETA] Ugh. This is annoying

1 Like

yea i have heard problems with that script. My suggestion would be dont copy paste scripts. Look them over and change it. Some of them may have issues as stated above

1 Like

TBH it is technically true @Briglair

The deletevehicle native -requires- that the vehicle be a mission entity to delete it. However, removing it set as a mission entity increases risk of standardized cleanup when the user is away from the vehicle.

I don’t think Brig or I either are guilty of that.

I don’t know Brig’s situation - but mine is related to a script written by another member of the community that I’ve spent a lot of time pouring over - discovering any existing issues - and addressing them.

The intent of continuing the thread is to relay relevant information to anyone else encountering similar issues in the future.
This isn’t StackOverflow - but it sometimes can be the closest thing for FiveM/GTA

@Briglair

I’ve isolated the root of my issue - Im assuming you are running at least some scripts that interact with vehicles, or set them as mission entities?

Ohh… I’m excited to hear. Yes, I am setting as mission entities and playing with extras.

Well - off the cuff:

Vehicles dont get deleted with players in them by an off chance. And the deletevehicle native can only do this when the vehicle is a mission entity.

First off - have you pulled up the F8 client debug console when this happens? I’d be interested to see if any error is tossed in there.

I don’t remember if I looked in the F8 console or not. I think I did, but I can’t remember. Also, these vehicles were being deleted as they were being driven. They were occupied.

I haven’t played with it, or experienced it for a while. Haven’t been doing any coding with cars or anything recently.

Well, to give some insight - as I was experiencing it in two different situations:

In one, it was only after LS Customs were used - and it appears to be an issue of the module itself not properly tracking entities.
When one user would go in, and customize - later on if another user pulled out a vehicle from a garage, or used customs (sometimes much later as the customs functionality is in an async thread) it would clean up the users vehicle as it thought it was another users entity.

In another situation, I was calling SetEntityAsMissionEntity and it was conflicting with the flow of a script changing vehicle state. In this case, I was not calling what entity I was setting as a mission entity - and it would randomly delete it as a result.

So query: Whenever using SetEntityAsMissionEntity are you defining exactly what entity you are calling this on - by entity ID?

1 Like

It could be the setmissionentity thing. I have no script that cleans up/deletes vehicles. I’m looking through the code, and I do check to see if the vehicle exists before setting it.

First off - I’d try looking for where you are setting as mission entity and make sure you are properly defining what entity it is. Not all natives return specifically an entity ID. What native are you using to define what entity you are setting as mission?

I’m using C# and the methods included with it. https://github.com/citizenfx/fivem/blob/5db7a5cee1ae1de65b98ffc8c9a19521d7567352/code/client/clrcore/External/Player.cs#L587

Couple things I would try:

Comment out the usage of SetMissionAsMissionEntity to see if that stops the problem

Also - try using GET_VEHICLE_PED_IS_USING to get the entity ID?

Hello. Did you find a solution?