Jump to content
Uro

Some SQL Events I had laying around

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! :)

 

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...