Jump to content

Some SQL Events I had laying around


Uro

Recommended Posts

Since I'm taking a break from Epoch/Arma2, I thought someone here might get some use out of these SQL EVENT Scripts I had laying around, mostly just housekeeping scripts :)

 

I'm fairly sure similar scripts are laying around these forums in various places.
 
 

I'll assume since your reading this, you know how to add sql event scripts to your database, and understand how to edit the below to your needs.

 

No further assistance shall be provided by myself with these.

 

 

 
RemoveBlownUpVehicles.sql

DROP EVENT IF EXISTS RemoveBlownUpVehicles;
CREATE EVENT RemoveBlownUpVehicles
   ON SCHEDULE EVERY 2 DAY
   COMMENT 'Removes destroyed vehicles'
   DO
     DELETE FROM object_data WHERE Damage = 1
;

 
The above code will remove anything in the Object_Data table where the damage is set to 1, I.E. Destroyed.
Event is scheduled every 2 days.
 

 

RemoveOldCharacterData.sql

 

DROP EVENT IF EXISTS RemoveOldCharacterData;
CREATE EVENT RemoveOldCharacterData
   ON SCHEDULE EVERY 2 DAY
   COMMENT 'Removes old character data'
   DO
     DELETE FROM character_data WHERE Alive = 0
;

 

WARNING:  The above event script will make certain epoch scripts that rely on character data such as EVAC Chopper not function properly, due the the database re-using Character ID slots that have been cleared and assigning them to new players.

 

The above code will remove anything from the Character_Data table where Alive = 0 , I.E. Dead.

Event is scheduled every 2 days.

 

 

 

RemoveOldPlayerLogins.sql

 

DROP EVENT IF EXISTS RemoveOldPlayerLogins;
CREATE EVENT RemoveOldPlayerLogins
   ON SCHEDULE EVERY 1 DAY
   COMMENT 'Removes old player login data'
   DO
     DELETE FROM player_login WHERE Datestamp < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY)
;

 

The above code will remove anything from the player_login table where the datestamp is older than 30 Days.

Event runs once a day.

 

 

 

RestockTraders.sql

 

CREATE EVENT RestockTraders
    ON SCHEDULE EVERY 1 DAY
    DO
    UPDATE `traders_data` SET qty=30 WHERE qty<=5
;

 

The above code will restock the traders_data table up to a quantity of 30 where the current items quantity is less than 5.

Event runs once a day.

 

 

 

UnlockAbandonedVehicles.sql

 

CREATE EVENT UnlockAbandonedVehicles
    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 `CharacterID` > 0 AND `Classname` NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL
;

 

The above code will UNLOCK (Set CharacterID ZERO) anything in the object_data table that is NOT a Vault/Safe/Lockbox/Wooden Storage Shed, Any form of Tent.

So it effectively Removes the keys of any vehicles that haven't been interacted with in a 14 DAY period.

Event is scheduled once a day.

 

 

NB: Will need modified if any new storage options come into play.

NBB: A similar event script is planned for the 1.0.5 database update, if not already implemented within 1.0.5 Database Events.

 

 

Enjoy the beanz! :)

 

 

 

 

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