Jump to content
  • 0

I need two Sql's (one to set damage and one to remove abandoned bases)


Bricktop

Question

Hey guys I've been reading so many posts about this and honestly I've become more confused than anything. I just want to run two events to take care of my base decay/maintenance/removal.

I already understand the basics : 

In my hive I set to -1

=============================================

I currently have this sql to set damage: 

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

=============================================

BUT I also found this: Is it better?

UPDATE `object_data`
SET `Damage` = IF( `Damage` = 0.0, 0.1, `Damage` + 0.1 )
WHERE `LastUpdated` <= DATE_SUB(NOW(), INTERVAL 1 DAY)
AND `Classname` REGEXP 'wall|floor|door|ladder|stair'

============================================

I found this sql to remove the decayed / abandoned bases:

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)

============================================

MY GOAL: Set bases to decay daily and require maintenance ALSO to have all abandoned bases completely removed from the server after 7 days untouched.

============================================

Not exactly sure what sql's to run here - Thanks for any assistance sorting this out ... 

/////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

E D I T ::

This is what I'm trying - Will it work? (RUNNING ON TEST SERVER- NO BASES) Don't want to delete bases on live server by mistake.

(Every 2 hours with restart) Set damage: UPDATE `object_data`SET `Damage` = IF ( `Damage` = 0.0, 0.1, `Damage` + 0.1 ) WHERE `LastUpdated` <= DATE_SUB(NOW(), INTERVAL 1 DAY) AND `Classname` REGEXP 'wall|floor|door|ladder|stair'

(Once a day) Remove old bases: DELETE FROM `object_data` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY)

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

SET `Damage` = IF( `Damage` = 0.0, 0.1, `Damage` + 0.1 )
WHERE `LastUpdated` <= DATE_SUB(NOW(), INTERVAL 1 DAY)
AND `Classname` REGEXP 'wall|floor|door|ladder|stair'

That will keep adding damage to the object 

Change the 'remove old objects and vehicles' event to 7 days and you'll be all good aslong as you have the objects damage set to 0.1 or more

 

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