[Release] Remove vehicles 2.0

FiveM Remove Vehicles

This is a simple script for FiveM to get rid off vehicles that people leave after they disconnect. There has always been an issue with leftover vehicles, so this script will automatically delete not used cars. It does not restrict number of vehicles that players are able to spawn, it just removes all of the vehicles spawned by player that disconnects.

Installation

To download go to releases tab and download latest zipped release. Unzip and place RemoveVehicles_2_0 folder in your resources folder, then start the resource in your server.cfg.

Issues

Feel free to comment or file an issue on github if something is not working as intended (it is tough for me to test this script alone in all possible scenarios, because it requires multiple people to test it out) or fork it and modify as you want.

Note: After hearing some feedback, it seems that vehicle removal is still not 100% reliable, I will be experimenting with it in my spare time and providing updates to hopefully fix this.

Source code

Source code

Update log:

  • v2.1.2 - Made source local in server script, added NetworkConcealEntity, added additional logging, split into two releases (one for final use, one for debugging)
  • v2.1.1 - Updated manifest version to 44febabe-d386-4d18-afbe-5e627f4af937
13 Likes

Hello, I’ve gotten this error and I see nothing wrong with the __resource.lua :man_shrugging:


__resource.lua
image
I haven’t touched anything.

EDIT:
I just update manifest version to resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'

1 Like

Did updating manifest version fix it? Also try to rename your server folder so that it does not include white space in the folder name.

1 Like

It got rid of the error, but when my buddy left it didn’t delete the vehicles he spawned before or after the script was started.
maybe it just needs a server restart, which I’m not able to do right now, but yes it got rid of the error.

2 Likes

Alright, let me know if there’s still problem with removing vehicles after you restart the server. Also the way it currently works is it only identifies vehicles to delete that player has used, did he possibly spawn them and did not enter them?

2 Likes

He spawned them with the option to be inside them.
I’ll let you know.

1 Like

Whether to set offline time

Suppose the vehicle is only deleted 15 minutes after offline

1 Like

So you want to delay vehicle deletion by 15 minutes? There is currently no option to do that, I can add an option like that in the future if there is a need for feature like that.

3 Likes

Yes, I hope there is such an option.
Thank you very much .

1 Like

Cool script, and cool idea. I love the fact that you’ve made a simple script that we’ve been needing in this community for such a long time now. This certainly will reduce the lag of some servers!

2 Likes

How this going on when people disconnect and came back in about 5 a 10 mins. Is the vehicle then already deleted or does the script have a timer for each player that disconnect? or a general timer?

2 Likes

Right now it deletes vehicles instantly after disconnection, I’ll probably add some kind of timer as it has already been requested.

4 Likes

How the hell you guys get vehicles not to despawn them selfs? I’m fighting for vehicles despawning them selfs for months, lol. Here people fighting to get them to DESPAWN. What the hell…
My question would be HOW TO NOT DELETE VEHICLES RANDOMLY… :smiley:

The way it works, is when player leaves, the engine marks the vehicle as no longer needed ( SetEntityAsNoLongerNeeded() or SetVehicleAsNoLongerNeeded()) and in theory it should get deleted automatically as the engine sees fit. That usually means that if there are no people nearby, vehicle should get deleted. However, it doesn’t always do it’s job that well and then there’s also problem when people are always nearby and it just does not get deleted. That is the problem that this script is trying to fix.

When it comes to your problem, the answet would probably be native SetEntityAsMissionEntity(), if you mark vehicle like that it should not get deleted automatically.

This native takes some arguments

SetEntityAsMissionEntity(vehicle, false, false)

should be fine, those two boolean values are described as not having any effect in the docs.

1 Like

Please add config option to make a delay before deleting it, like 5-10 minutes, because someone’s game can crash and if they were in roleplay at the middle of nowhere it’s bad… It will be cool if the player join in before 5-10 minutes, the car to stay here, but if the player didn’t joined, to remove the car.

5 Likes

This script will be a big help :slightly_smiling_face::slightly_smiling_face:

We always have a issue of cars vanishing if a player disconnects.
Nice work.