Jump to content
  • 0

How to clean old vehicles


FragZ

Question

I am using dayz.st and I would like to know if there is a way to delete all vehicles unused for over like... 2-3 weeks.

I know in the database there is a tab with *last updated*. Is there a way (sql or whatever) to remove all of those who are too old? Our server is getting stacked by people buying vehicles and leaving etc... plus the normal 500 vehicle spawns.


Help :)

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

This sql deletes vehicles not used in 7 days that have some damage

 

BEGIN
DELETE FROM dayz_epoch.object_data
WHERE object_data.LastUpdated < NOW() - INTERVAL 7 DAY
AND Hitpoints LIKE '%wheel_2_1_steering",1%'
AND Hitpoints LIKE '%wheel_2_2_steering",1%'
OR Hitpoints LIKE '%motor",1%'
OR Hitpoints LIKE '%karoserie",1%'
OR Hitpoints LIKE '%Pravy zadni tlumic",1%'
OR Hitpoints LIKE '%engine",1%';
END

This sql unlocks vehicles not used in 7 days

UPDATE `object_data` SET `CharacterID` = 0 WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 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

 

This sql deletes vehicles not used in 7 days that have some damage

 

BEGIN
DELETE FROM dayz_epoch.object_data
WHERE object_data.LastUpdated < NOW() - INTERVAL 7 DAY
AND Hitpoints LIKE '%wheel_2_1_steering",1%'
AND Hitpoints LIKE '%wheel_2_2_steering",1%'
OR Hitpoints LIKE '%motor",1%'
OR Hitpoints LIKE '%karoserie",1%'
OR Hitpoints LIKE '%Pravy zadni tlumic",1%'
OR Hitpoints LIKE '%engine",1%';
END

This sql unlocks vehicles not used in 7 days

UPDATE `object_data` SET `CharacterID` = 0 WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND `CharacterID` > 0 AND `Classname` NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

Gives me this error:

Error

SQL query:

BEGIN DELETE FROM dayz_epoch.Object_DATA WHERE Object_DATA.LastUpdated < NOW( ) - INTERVAL 14 DAY AND Hitpoints LIKE '%wheel_2_1_steering",1%' AND Hitpoints LIKE '%wheel_2_2_steering",1%' OR Hitpoints LIKE '%motor",1%' OR Hitpoints LIKE '%karoserie",1%' OR Hitpoints LIKE '%Pravy zadni tlumic",1%' OR Hitpoints LIKE '%engine",1%';

 

MySQL said: dot.gif

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM dayz_epoch.Object_DATA

WHERE Object_DATA.LastUpdated < NOW() - INTE' at line 2

Link to comment
Share on other sites

  • 0

I got it working by removing some parts.  Reason was DayZ.ST has diff database setup. Final code was this:

 

DELETE FROM Object_DATA
WHERE Object_DATA.LastUpdated < NOW() - INTERVAL 7 DAY
AND Hitpoints LIKE '%wheel_2_1_steering",1%'
AND Hitpoints LIKE '%wheel_2_2_steering",1%'
OR Hitpoints LIKE '%motor",1%'
OR Hitpoints LIKE '%karoserie",1%'
OR Hitpoints LIKE '%Pravy zadni tlumic",1%'
OR Hitpoints LIKE '%engine",1%';
Link to comment
Share on other sites

  • 0
WHERE object_data.LastUpdated < NOW() - INTERVAL 7 DAY

Does this affect any built objects?  Last time I tried to clear up my unused vehicles I deleted most the bases my players made.... I wasn't popular.

 

 

How many bases have an engine?

Link to comment
Share on other sites

  • 0

If you add variables where you use the damaged parts, bases should stay. What I personaly did, is I did that line since I removed only few vehicles, and instead of 7 days I put 28. Server is around a month old on my side so bases are good... they were updated after that timestamp.

If you really don't want to take any chances, add the

AND Hitpoints LIKE '%wheel_2_1_steering",1%'
AND Hitpoints LIKE '%wheel_2_2_steering",1%'
OR Hitpoints LIKE '%motor",1%'
OR Hitpoints LIKE '%karoserie",1%'
OR Hitpoints LIKE '%Pravy zadni tlumic",1%'
OR Hitpoints LIKE '%engine",1%';

part on the code.

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