Jump to content

Looking for DB event.


Affraid

Recommended Posts

I was using this Web based PHP script. 

 

 

I'm looking for a Database Event to run weekly or monthly. Having a problem with too many vehicles spawning for no reason. I think this might help clean up DB for now. What i've been reading others are having same problem with vehicles flooding server. 

Link to comment
Share on other sites

ok you could try something like this

 

SELECT * FROM
dayz_epoch.object_data OD
WHERE 1 = 1
AND OD.inventory IS NOT NULL
AND OD.inventory NOT LIKE '[]'
AND OD.classname NOT LIKE '%storage%'

 

The above code should return only vehicles.  You will want to run this and double check to see what returns.  If it returns non-vehicles you can tweak the query till it doesn't.

 

Personally, I clean up vehicles based on their timestamp.  At 5 days I unlock vehicles, at 15 days, I delete them.

Link to comment
Share on other sites

ok you could try something like this

SELECT * FROM
dayz_epoch.object_data OD
WHERE 1 = 1
AND OD.inventory IS NOT NULL
AND OD.inventory NOT LIKE '[]'
AND OD.classname NOT LIKE '%storage%'

The above code should return only vehicles.  You will want to run this and double check to see what returns.  If it returns non-vehicles you can tweak the query till it doesn't.

 

Personally, I clean up vehicles based on their timestamp.  At 5 days I unlock vehicles, at 15 days, I delete them.

ok I will give it a try . TY 

Link to comment
Share on other sites

ok I will give it a try . TY 

 

Here is my epoch cleanup script.  I may have taken some ideas from MGT or others here, I can't remember fully but this is not entirely my work.

 

Also you will need to change the name of the database from dayzepoch to whatever your db name is (most likely dayz_epoch)

 

USE dayzepoch;
 
DELIMITER $$
DROP PROCEDURE IF EXISTS dayzepoch.proc_CleanupMain$$
CREATE PROCEDURE dayzepoch.proc_CleanupMain ()
SQL SECURITY INVOKER
BEGIN
  -- Delete damaged vehicles
  DELETE
    FROM object_data
  WHERE Damage = '1';
 
 
  -- unlock vaults
  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 `CharacterID` > 0
  AND `Classname` NOT IN ('VaultStorage')
  AND `Inventory` <> '[]'
  AND `Inventory` IS NOT NULL
  AND Classname NOT LIKE '%land%'
  AND classname NOT LIKE '%warehouse%'
  AND Classname NOT LIKE '%castle%';
 
  DELETE
    FROM object_data
  WHERE (Classname LIKE '%Storage",1%'
    OR Classname LIKE '%House",1%'
    OR Classname LIKE '%Shed",1%'
    OR Classname LIKE '%Shack",1%')
    AND
    (
    Inventory NOT LIKE '[]'
    AND Inventory NOT LIKE '[[[],[]],[[],[]],[[],[]]]'
    )
    AND object_data.LastUpdated < NOW() - INTERVAL 30 DAY;
 
  -- unlock old vehicles
 
  UPDATE `object_data`
  SET `CharacterID` = 0
  WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
  AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
  AND `CharacterID` > 0
  AND `Classname` NOT IN ('VaultStorage', 'LockboxStorage', 'VaultStorageLocked', 'LockboxStorageLocked')
  AND `Inventory` <> '[]'
  AND `Inventory` IS NOT NULL;
  UPDATE `object_data`
  SET `CharacterID` = 0
  WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
  AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
  AND `CharacterID` > 0
  AND `Classname` NOT IN ('VaultStorage', 'LockboxStorage', 'VaultStorageLocked', 'LockboxStorageLocked')
  AND `Inventory` <> '[]'
  AND `Inventory` IS NOT NULL;
 
  -- delete empty tents and sheds
  DELETE
    FROM object_data
  WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
    AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
    AND ((`Inventory` IS NULL)
    AND Classname LIKE '%TentStorage",1%'
    AND (`Inventory` = '[]' OR (`Inventory` = '[[[],[]],[[],[]],[[],[]]]'))
    );
 
END
$$
 
DELIMITER ;
Link to comment
Share on other sites

  • 3 weeks later...

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