Jump to content
  • 0

A question about setting damage for maintenance


BetterDeadThanZed

Question

This is what I use to set damage to players can maintain them:

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

How can I update that to EXCLUDE light poles?

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Maybe something like:

UPDATE `Object_DATA` SET `Damage`=0.1 WHERE `ObjectUID` <> 0 AND `CharacterID` <> 0 AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') ) AND `Classname` NOT LIKE 'YOUR_CLASS_NAME'
Link to comment
Share on other sites

  • 0

 

Maybe something like:

UPDATE `Object_DATA` SET `Damage`=0.1 WHERE `ObjectUID` <> 0 AND `CharacterID` <> 0 AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') ) AND `Classname` NOT LIKE 'YOUR_CLASS_NAME'

 

Ok, thanks! I'll try that.

Link to comment
Share on other sites

  • 0

Yes, they are. So I have to decide do I want players lightpoles not working, which is what happens when 0.1 damage is set on them, or have them standing alone after a base is deleted. I'd rather them standing after the base is gone. At least that way I know they are left over and can be deleted.

Link to comment
Share on other sites

  • 0

 

Maybe something like:

UPDATE `Object_DATA` SET `Damage`=0.1 WHERE `ObjectUID` <> 0 AND `CharacterID` <> 0 AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') ) AND `Classname` NOT LIKE 'YOUR_CLASS_NAME'

 

This will disallow your item to be maintained, but the item will still be removed  ( i thought ligpoles will be removed, arent they in the classes that will be removed? ). But the original delete after  x days, actually looks at the updated TIME in the database

 

a simple solution is running a database event every day updating items to current data that you dont want to dissapear

UPDATE `Object_DATA` SET `LastUpdated`= CURRENT_TIMESTAMP WHERE `Classname` in ("DZE_lightPole");

thats not the official classname, just an example

Link to comment
Share on other sites

  • 0

This will disallow your item to be maintained, but the item will still be removed  ( setDamage is so the item can be maintained ingame). But the original delete after  x days, actually looks at the updated TIME in the database

 

a simple solution is running a database event every day updating items to current data that you dont want to dissapear

UPDATE `Object_DATA` SET `LastUpdated`= CURRENT_TIMESTAMP WHERE `Classname` in ("DZE_lightPole");

thats not the official classname, just an example

 

Good point... BTW, the classname is "LightPole_DZ".

Link to comment
Share on other sites

  • 0

Perhaps I'm misunderstand you, Zed, but I was under the impression (as Zupa also implies) that the poles will vanish as part of the normal cleanup process when remaining unmaintained (as long as you don't take additional measures as Zupa has suggested one).

 

If I understand you correctly you're looking for a way to

  • not damage the items (-> they cannot be maintained)
  • while not having them automatically removed during cleanup.

I assume, somewhere (variables.sqf?) there is a list of items removed during cleanup. If that's the case one could simply delete them, there...

 

Edit...ninjaed

Link to comment
Share on other sites

  • 0

Perhaps I'm misunderstand you, Zed, but I was under the impression (as Zupa also implies) that the poles will vanish as part of the normal cleanup process when remaining unmaintained (as long as you don't take additional measures as Zupa has suggested one).

 

If I understand you correctly you're looking for a way to

  • not damage the items (-> they cannot be maintained)
  • while not having them automatically removed during cleanup.

I assume, somewhere (variables.sqf?) there is a list of items removed during cleanup. If that's the case one could simply delete them, there...

 

When you use the SQL query to set damage on items, it sets the damage to 0.1. For light poles, this disables them. I don't want them to become disabled because then even when you maintain them, they won't work again until the next restart. I'll just settle with any left over light poles if someone stops maintaining their base and delete them manually.

Link to comment
Share on other sites

  • 0

Perhaps I'm misunderstand you, Zed, but I was under the impression (as Zupa also implies) that the poles will vanish as part of the normal cleanup process when remaining unmaintained (as long as you don't take additional measures as Zupa has suggested one).

 

If I understand you correctly you're looking for a way to

  • not damage the items (-> they cannot be maintained)
  • while not having them automatically removed during cleanup.

I assume, somewhere (variables.sqf?) there is a list of items removed during cleanup. If that's the case one could simply delete them, there...

 

Edit...ninjaed

 

Hey man, 

 

I never really looked alot in the delete code of old objects? where does this happen? 

 

It should be in server_monitor, but i dont really see anything that comes near that. 

 

I always thought that happens in the hivdeext.dll itself ^^

 

And DZE_maintainclass is just to specify which items need maintaining right?

Link to comment
Share on other sites

  • 0

I don't really know, I don't even remember if I once knew ;-)

 

Now, that you say it, I rember the dreaded DB event removeObjectOld that removes anything older than 24/42 days, unconditionally. But that one is not triggered by the CleanupPlacedAfterDays interval in HiveExt.ini, so you may be right about hiveext.dll.

 

But my impression was that not everything built was removed after that time.....

Link to comment
Share on other sites

  • 0

I have HiveExt.ini set not to remove anything. I use SQL events to clean up items. I also have this in my custom variables:

DZE_maintainClasses = ["ModularItems","DZE_Housebase","LightPole_DZ","BuiltItems","Plastic_Pole_EP1_DZ","Fence_corrugated_DZ","CanvasHut_DZ","ParkBench_DZ","MetalGate_DZ","StickFence_DZ","DesertCamoNet_DZ","ForestCamoNet_DZ","DesertLargeCamoNet_DZ","ForestLargeCamoNet_DZ","DeerStand_DZ","Scaffolding_DZ","FireBarrel_DZ"];

I have an SQL even that sets damage on buildables:

UPDATE `Object_DATA` SET `Damage`=0.1 WHERE `ObjectUID` <> 0 AND `CharacterID` <> 0 AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') ) AND `Classname` NOT LIKE 'LightPole_DZ'

Then, anything not maintained in 2 weeks is deleted:

DELETE FROM `Object_DATA` WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY)
Link to comment
Share on other sites

  • 0

Ah, that's done explicitely, then and you would simply use the same

AND `Classname` NOT LIKE 'LightPole_DZ'

in both, the damage event and the deletion event.

 

Only for reference, the official cleanup method, picked from (Zupa was right) HiveExt.dll's SqlObjDataSource.cpp

	if (_cleanupPlacedDays >= 0)
	{
		string commonSql = "FROM `"+_objTableName+"` WHERE `Instance` = " + lexical_cast<string>(serverId) +
			" AND `ObjectUID` <> 0 AND `CharacterID` <> 0" +
			" AND `Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL "+lexical_cast<string>(_cleanupPlacedDays)+" DAY)" +
			" AND ( (`Inventory` IS NULL) OR (`Inventory` = '[]') )";

		int numCleaned = 0;
		{
			auto numObjsToClean = getDB()->query(("SELECT COUNT(*) "+commonSql).c_str());
			if (numObjsToClean && numObjsToClean->fetchRow())
				numCleaned = numObjsToClean->at(0).getInt32();
		}
		if (numCleaned > 0)
		{
			_logger.information("Removing " + lexical_cast<string>(numCleaned) + " empty placed objects older than " + lexical_cast<string>(_cleanupPlacedDays) + " days");

			auto stmt = getDB()->makeStatement(_stmtDeleteOldObject, "DELETE "+commonSql);
			if (!stmt->directExecute())
				_logger.error("Error executing placed objects cleanup statement");
		}
	}

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