Jump to content
  • 0

SQL object delete script


lwbuk

Question

Hi folks, Im getting myself in a mess trying to trim my database down from abandoned bases.

What Ive done so far:

All bases are indestructable. I want to keep this the case.

On the 18th, I ran a script to update all objects 'last updated' time to be the 18th.

I edited my init.sqf to have maintain when damage is 0

I editied fn_selfactions to make maintenance free

Ive pre warned all players that they must maintain thier bases every 7 days starting from the 21st.

 

What I want to acheive.. I thought I had saved an sql event in my bookmarks that would delete all objects that havent been updated in the previous 7 days, however I cant find it.

I found this one

 

Spoiler
DROP EVENT IF EXISTS `removeObjectOld`;
DELIMITER ;;
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)
;;
DELIMITER ;

But I tried it on my test server and it didnt delete anything. I changed the interval 24 day and interval 42 day to 1 day to try and it still didnt delete anything. SQL isnt my forte and I dont know what Im doing wrong.

I just want a scipt I can run that deletes anything that hasnt been updated in the previous 7 days, be it automatic or one I have to run manually.. I have navicat or phpmyadmin acsess to the database and seemingly can create events without any issues, as I have run a charcter data one without issues, I just dont know what the correct event is for this purpose!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

You need to set damage through database events and the hiveExt.ini halfway down says cleanupplaced after days  , set that to the amount of days you want .

Keep in mind the damage being done by the database event has to come to damage 1 for the cleanup from hiveExt to work .

so for example make the database do 0.2 damage every day is 1 damage in 5 days then the cleanup could be set to cleanupplaced after 6  days , but this is just an example  .

Link to comment
Share on other sites

  • 0

Thanks for the replys.

Currently Ive got the following mysql events running and defaultcleanup set to -1 in Hive.ext so Mysql does all the work, but something is confusing me.

Spoiler

DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY)

Spoiler

UPDATE `object_data` SET `Damage`=0.2 WHERE `ObjectUID` <> 0 AND `CharacterID` <> 0 AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') )

I did a test, where I placed some walls and shot them until they were are about 80/100 on damage. This allowed me to maintain via the plotpole as expected. By maintaining, they went back to 100/100 as they should.

I did another test, again, shot the wall until it was 80/100 and then waited for restart.

After restart, the wall was 100/100 again.

With this being the case, how is the sql cleanup going to work if all items go back to 100% after each restart, or does the SQL event force the damage to save to the database whereas shooting at the wall in game doesnt?

Sorry for such noob questions, I really do try figure out as much as I can on my own, but sometimes my head just refuses to work logically and I get stuck in a rut trying to figure stuff out!

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
  • Discord

×
×
  • Create New...