Jump to content
  • 0

Purge Abandoned Vehicles


tylerjohnson

Question

I know in traditional DayZ or even Overwatch there is an easy way to purge the vehicles that haven't been touched in a few days or even weeks depending on what I wanted. It seems the day Epoch stores the vehicles in the database, the time is only for the creation time not an update time. Is there an easy way to purge abandoned vehicles?

 

As my server rotates through new and old players I need an easy way to purge out old vehicles.

 

Thanks for any input!

Link to comment
Share on other sites

21 answers to this question

Recommended Posts

  • 0

In my server I don't purge the vehicles, but unlock them instead, so players can use or sell the abandoned vehicles.

 

This only works for epoch 1.0.2.4 and higher, as lower versions don't keep info on a vehicle's last use.

 

What I did was make a database event trigger every day, looking for vehicles that are locked and not used or created in the last 7 days, and simply remove the lock.

 

Here is the SQL query I used to add the event:

CREATE EVENT unlockAbandonedVehicles
    ON SCHEDULE EVERY 1 DAY
    DO
      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','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL
;

For vehicles in the object_data table, CharacterID holds the lock info, 0 means there's no lock. I also added a check for the inventory to make sure the query doesn't affect ownership of modular buildings and a classname check as not to affect the codes on safes and lockboxes. I'm not sure if there's a need to check the creation time, but I added it in anyway in case last_updated comes up at a lower value than the creation time when the vehicle gets spawned.

Link to comment
Share on other sites

  • 0

Hi,

 

Just a quick check... To make sure there's no problems, I ran a 'kind of' modified version of the below to check that it different effect any buildables - Not sure if I did something wrong, but it did appear to include some...

 

Code I ran:

 

select * from object_data where classname NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked') AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

 

Worrying classnames included in the results:

WoodShack_DZ
StorageShed_DZ
TentStorageDomed
TentStorageDomed2
TentStorage

 

Did I do something wrong, or are the shacks and sheds at risk with this MySQL query?

 

Thanks! 

 

Mike

Ps. Great idea though! I want to use it, just worried!

 

 

 

In my server I don't purge the vehicles, but unlock them instead, so players can use or sell the abandoned vehicles.

 

This only works for epoch 1.0.2.4 and higher, as lower versions don't keep info on a vehicle's last use.

 

What I did was make a database event trigger every day, looking for vehicles that are locked and not used or created in the last 7 days, and simply remove the lock.

 

Here is the SQL query I used to add the event:

CREATE EVENT unlockAbandonedVehicles
    ON SCHEDULE EVERY 1 DAY
    DO
      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
;

For vehicles in the object_data table, CharacterID holds the lock info, 0 means there's no lock. I also added a check for the inventory to make sure the query doesn't affect ownership of modular buildings and a classname check as not to affect the codes on safes and lockboxes. I'm not sure if there's a need to check the creation time, but I added it in anyway in case last_updated comes up at a lower value than the creation time when the vehicle gets spawned.

Link to comment
Share on other sites

  • 0

You can add these to the classname list in the query and they won't be affected.

`Classname` NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage')
Link to comment
Share on other sites

  • 0

In my server I don't purge the vehicles, but unlock them instead, so players can use or sell the abandoned vehicles.

 

This only works for epoch 1.0.2.4 and higher, as lower versions don't keep info on a vehicle's last use.

 

What I did was make a database event trigger every day, looking for vehicles that are locked and not used or created in the last 7 days, and simply remove the lock.

 

Here is the SQL query I used to add the event:

CREATE EVENT unlockAbandonedVehicles
    ON SCHEDULE EVERY 1 DAY
    DO
      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
;

For vehicles in the object_data table, CharacterID holds the lock info, 0 means there's no lock. I also added a check for the inventory to make sure the query doesn't affect ownership of modular buildings and a classname check as not to affect the codes on safes and lockboxes. I'm not sure if there's a need to check the creation time, but I added it in anyway in case last_updated comes up at a lower value than the creation time when the vehicle gets spawned.

 

It has no effect with this line: (

Link to comment
Share on other sites

  • 0

May want to just remove them so new vehicles can spawn, they are usually in much better shape then and abandoned and/or locked vehicles. I would just remove the safes and lockboxes that are not used at some point less objects = more performance.

 

I would like to do this but how exactly? Can you be more specific please?

 

Thank you in advance.

Link to comment
Share on other sites

  • 0

I would like to do this but how exactly? Can you be more specific please?

 

Thank you in advance.

 

just use this SQL.

[font='Helvetica Neue', Arial, Verdana, sans-serif]CREATE EVENT unlockAbandonedVehicles[/font]
    ON SCHEDULE EVERY 1 DAY
    DO
      DELETE FROM `object_data` 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','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL
;
Link to comment
Share on other sites

  • 0

I'm running two versions of this , one that checks after 7 days then unlocks abandoned vehicles and another that checks after 9 days then deletes them if they still remain untouched.  This gives players who have lost keys the option of getting it back an maybe selling it, but if nobody claims it after 9 days, it's deleted along with safes.  Thanks for the sql btw, I'm always looking for clever ways to automate my server tasks :)

Link to comment
Share on other sites

  • 0

While were' on the subject of SQL and deleting items.  I'm running the sql on my server to update the buildables so they don't get deleted, so long as the player logs in every 7 days.  I got it from the wiki.  The walls, floors etc are fine, but for some reason locked doors and garage doors are being deleted after 7 days (even though I've got the hive setting to 24 days) .. Any ideas ? 

Link to comment
Share on other sites

  • 0

Currently, this code makes changes to all objects in the database.. What would I need to add to make it only update buildables? 

UPDATE Object_DATA
      SET    Datestamp   = CURRENT_TIMESTAMP
      WHERE  ObjectUID   <> 0
      AND    CharacterID <> 0
      AND  ((Inventory IS NULL) OR (Inventory = '[]'))
      AND EXISTS (SELECT 1
                  FROM   Character_DATA c
                  WHERE  c.PlayerUID = (SELECT p.PlayerUID
                                        FROM   Player_DATA p,
                                               Character_DATA c2
                                        WHERE  p.PlayerUID = c2.PlayerUID
                                        AND    c2.CharacterID = Object_DATA.CharacterID)
                  AND    c.Alive = 1
                  AND    c.LastLogin   > NOW() - INTERVAL 1 WEEK)
Link to comment
Share on other sites

  • 0

I'm running two versions of this , one that checks after 7 days then unlocks abandoned vehicles and another that checks after 9 days then deletes them if they still remain untouched.  This gives players who have lost keys the option of getting it back an maybe selling it, but if nobody claims it after 9 days, it's deleted along with safes.  Thanks for the sql btw, I'm always looking for clever ways to automate my server tasks :)

 

Could you share this mysql code? Currently I only have it set to delete unowned vehicles every 7 days, which encourages people not to use found vehicles as storage, encourages them to use the traders, and ensures a fresh supply of vehicles since hording is prevented, but if I could also automate the deletion of locked vehicles as you described, that would be cool too.

Link to comment
Share on other sites

  • 0

Could you share this mysql code? Currently I only have it set to delete unowned vehicles every 7 days, which encourages people not to use found vehicles as storage, encourages them to use the traders, and ensures a fresh supply of vehicles since hording is prevented, but if I could also automate the deletion of locked vehicles as you described, that would be cool too.

 

It's the code offered in the second post ? 

Link to comment
Share on other sites

  • 0

all of this seems like a great idea, on our server we are having so many problems with vehicle clean up

 

i have gone through this thread and as i know far to little as to SQL i need a bit of help

 

can someone please post the script in one post with instructions on how to get it to work?

 

the parts i am interested in would be

 

unlock vehicles after 7 days, delete after 14 days and change the code of a safe to 0000 after 1 month

Link to comment
Share on other sites

  • 0

all of this seems like a great idea, on our server we are having so many problems with vehicle clean up

 

i have gone through this thread and as i know far to little as to SQL i need a bit of help

 

can someone please post the script in one post with instructions on how to get it to work?

 

the parts i am interested in would be

 

unlock vehicles after 7 days, delete after 14 days and change the code of a safe to 0000 after 1 month

Try these SQL query to add the events

 

CREATE EVENT unlockAbandonedVehicles

    ON SCHEDULE EVERY 1 DAY

    DO

      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','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

;

CREATE EVENT deleteAbandonedVehicles

    ON SCHEDULE EVERY 1 DAY

    DO

      DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `CharacterID` > 0 AND `Classname` NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

;

CREATE EVENT unlockAbandonedSafes

    ON SCHEDULE EVERY 1 DAY

    DO

      UPDATE `object_data` SET `CharacterID` = 0 WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

;

CREATE EVENT deleteAbandonedSafes

    ON SCHEDULE EVERY 1 DAY

    DO

      DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 28 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 28 DAY) AND `CharacterID` > 0 AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

;

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