Jump to content
  • 0

Is there some way to clean up (delete) unused locked vehicles?


robbiedarza

Question

Hello there, I have a lot of locked vehicles all over my map, and I cant delete them in case they are still being used.

 

So I was wondering if there was a script or something that would auto delete vehicles that have not been used within a month.

 

 

Many thanks

 

 

Robbie

 

 

Link to comment
Share on other sites

21 answers to this question

Recommended Posts

  • 0
DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY) AND `CharacterID` > 0 AND `Classname` NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked') AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL
Link to comment
Share on other sites

  • 0

Ok thank you very much, I am using dayz.st does anyone know what i have to do plz?

 

Never done anything like that

 

many thanks

 

robbie

 

not sure if dayz.st allows access to the database, but you would connect to your mysql database, and depending on the app used to connect the database, click events and new event from there.  i use navicat to connect to the database.  i also had to run this query as events were turned off by default

SET GLOBAL event_scheduler = ON;
Link to comment
Share on other sites

  • 0

We have done this on out server, but in a odd and roundabout way. First, we have updated our Hive.dll to change how it handles the database. It loads the Modular Building objects first, then the vehicles, just like the 1.0.4 Hive.dll will (all this was done in house before the the 1.0.3 update.) It also handles the object age updating, by doing in inside the hive.dll instead of an event in the database. We disabled the 'UPDATE CURRENT TIME' event in the database that was triggered every time a vehicle was altered.

 

Then we setup events for the database to run different cleanups:

  • First it checks of the vehicle is locked, if so (and it isnt a fuel truck) and its a week old then it changes the 'character id' variable from what ever key value to '0', thus unlocking the vehicle permanently. It also updates the vehicle's time stamp to the current time.
  • Next it looks for unlocked vehicles that are 6 days old and repairs them to 100%, but it does not update the vehicle's 'Last_Updated' varible.
  • Finally it looks for vehicles that have not been touched in 7 days, and are fully repaired, if its true, It deletes the vehicle.

Its quite nice and helps rotate the vehicles out of my server and clean up vehicles left play inactive player, and its completely customizable.

 

If there is any one interested, i can offer a tutorial on all the steps to do this.

Link to comment
Share on other sites

  • 0

We have done this on out server, but in a odd and roundabout way. First, we have updated our Hive.dll to change how it handles the database. It loads the Modular Building objects first, then the vehicles, just like the 1.0.4 Hive.dll will (all this was done in house before the the 1.0.3 update.) It also handles the object age updating, by doing in inside the hive.dll instead of an event in the database. We disabled the 'UPDATE CURRENT TIME' event in the database that was triggered every time a vehicle was altered.

 

Then we setup events for the database to run different cleanups:

  • First it checks of the vehicle is locked, if so (and it isnt a fuel truck) and its a week old then it changes the 'character id' variable from what ever key value to '0', thus unlocking the vehicle permanently. It also updates the vehicle's time stamp to the current time.
  • Next it looks for unlocked vehicles that are 6 days old and repairs them to 100%, but it does not update the vehicle's 'Last_Updated' varible.
  • Finally it looks for vehicles that have not been touched in 7 days, and are fully repaired, if its true, It deletes the vehicle.

Its quite nice and helps rotate the vehicles out of my server and clean up vehicles left play inactive player, and its completely customizable.

 

If there is any one interested, i can offer a tutorial on all the steps to do this.

Sounds pretty sweet....can you post info on how to do this?  I'm mostly a beginner at setting up the events...although I am learning a bit :)

Link to comment
Share on other sites

  • 0

yeah, ill set one up. I wont go much into the explanation, just do this and this and this type post. And you will need my custom hive.dll, i need to make sure its ok to give that out. (for both you and me) You will need some spicific tools and access to your server, from what i have heard about gsp's, that shouldnt be a problem.

Link to comment
Share on other sites

  • 0

Never heard of host that doesn't allow access to database :o  Lets not make this too complicated.

 

There is link to your database at Dayz.st control panel. Go there choose your epoch table and run this under SQL.

CREATE EVENT DeleteOldVehicles
ON SCHEDULE EVERY 1 DAY
COMMENT 'Removes unused vehicles'
DO
DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY) AND `CharacterID` > 0 AND `Classname` NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked') AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

I would do it with shorter timeline like 10 days.

Link to comment
Share on other sites

  • 0

Would this only delete unused vehicles if their inventory is empty? I have a lot of abandoned vehicles from players who no longer play on the server. I'd like to remove the vehicles even if their inventory is full.

Anyone have a trigger for this? I have so many vehicles on my Chernarus server from players who left.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...