A2Epoch:Server Installation Instructions Extended

From Epoch Mod Wiki
Jump to: navigation, search

In your mysql config my.ini add the line:

event_scheduler=ON

Next run the SQL query

SET GLOBAL event_scheduler = 1;

to enable the event scheduler.

Execute this add_recommended_mysql_events.sql SQL against every dayz epoch database:

DROP EVENT IF EXISTS updateStockDaily;
CREATE EVENT updateStockDaily
    ON SCHEDULE EVERY 1 DAY
    COMMENT 'Updates out of stock vendors'
    DO
      UPDATE `traders_data` SET qty=10 WHERE qty=0 AND afile<>'trade_any_vehicle' AND afile<>'trade_any_boat';
;
DROP EVENT IF EXISTS removeDamagedVehicles;
CREATE EVENT removeDamagedVehicles
    ON SCHEDULE EVERY 1 DAY
    COMMENT 'Removes damaged vehicles'
    DO
      DELETE FROM `object_data` WHERE Damage = 1;
;

Cleanup of unused items 1.0.2.4+[edit | edit source]

With the addition of the "LastUpdated" column to object_data you can now see when an object was last accessed and perform cleanup based on that.

This will remove all objects with completely empty inventory and that have not updated in the past 14 days and is older than 24 days old.

DROP EVENT IF EXISTS removeObjectEmpty; CREATE EVENT removeObjectEmpty

   ON SCHEDULE EVERY 1 DAY
   COMMENT 'Removes abandoned storage objects and vehicles'
   DO
     DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 24 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') OR (`Inventory` = '[[[],[]],[[],[]],[[],[]]]') )

This will remove all objects that are older than 42 days and that have not updated in the past 24 days regardless of inventory.

DROP EVENT IF EXISTS removeObjectOld; CREATE EVENT removeObjectOld

   ON SCHEDULE EVERY 1 DAY
   COMMENT 'Removes old objects and vehicles'
   DO
     DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 24 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 42 DAY)

Sets minor damage to walls so the game can identify when a maintain option should be available. It it recommended to have this set to half of your CleanupPlacedAfterDays value. The default is 6 days so "INTERVAL 3 DAY" should be used as shown below.

DROP EVENT IF EXISTS setDamageOnAge; CREATE EVENT setDamageOnAge

   ON SCHEDULE EVERY 1 DAY
   COMMENT 'This sets damage on a wall so that it can be maintained'
   DO
     UPDATE `object_data` SET `Damage`=0.1 WHERE `ObjectUID` <> 0 AND `CharacterID` <> 0 AND `Damage` = 0 AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') )