[Release] Automatic and Manual Vehicle Cleanup with server announcement for ESX

Hello everyone today I am presenting you my first script to release. This is simple one but I could not find it anywhere and I think it will be very useful for a lot of server owners out here!

It is a Automatic and Manual Vehicles cleanup for unoccupied vehicles which can be adjusted for the time you like the cleanup to start or by typing in the chat: /delallveh

Requirement is cron as the script uses the server time for the automatic cleanup:

Preview:

Installation:

  1. Download the resouce you can name it to whatever you like.
  2. Drag the folder into resources in your server
  3. Start (name of your folder)
  4. Enjoy

If you have any questions please don’t hesitate to ask!

Download:

8 Likes

Nice job.

Video Broken or recorded bad

Will ask some friends to test it out works perfect on 1080p for me. Thanks for the feedback!

Well I’m trying to look on the phone, maybe that’s why, going to get home and try to watch on PC

BryanLTU work good mate must be something with you try different browser perhaps ?

2 Likes

Does this remove only vehicles that has no driver inside?

Yes only the empty vehicles!

hi , is it really needed in the latest builds ? cause when an entity is out of scope and nobody is near it , it will be deleted afaik or am i wrong ?

What about players cars…? If a player spawns his vehicle and doesn’t drive it for about 30mns and vehicle cleanup is coming, will it despawn the vehicle…?

1 Like

So I will explain really quick how it works again. Every Vehicle that does not have player in it will be deleted after 30 seconds from the script initiating. If the person is in the car it will not be deleted, that’s the whole reason I added the 30 seconds so if people jumped out of their car can hop back in for a brief second and wait for the vehicle cleanup. This could be improved for example make it that if the car was unoccupied for lets say 2 minutes and the vehicle cleanup starts it will be deleted otherwise stay.

How can I increase this automatic time

1 Like

In server.lua
TriggerEvent(‘cron:runAt’, 0, 30, CleanUpCronTask)
TriggerEvent(‘cron:runAt’, 1, 30, CleanUpCronTask)
TriggerEvent(‘cron:runAt’, 2, 30, CleanUpCronTask)
TriggerEvent(‘cron:runAt’, 3, 30, CleanUpCronTask)

This means the cleanup will be done every hour so
0, 30 means 00:30 server time
1, 30 means 01:30 server time

If you want it lets say every 2 hours you can do
TriggerEvent(‘cron:runAt’, 2, 00, CleanUpCronTask)
TriggerEvent(‘cron:runAt’, 4, 00, CleanUpCronTask)

And so on.

Sorry what do you mean with that ?

I deleted the comment but anyway, what I said is that I don’t find it usefull if it doesn’t check if a player owns the car is going to be deleted in order to avoid the unnecesary cleanup in some vehicles… There are some natives that might help HasVehicleBeenOwnedByPlayer, IsVehiclePreviouslyOwnedByPlayer

Do you have anything like this perhaps for VRP! I am in desperate need

ill look into it myself but possible to remove all the esx stuff? xD