Jump to content

Clear Old Guilds Lands by Inactivity


Recommended Posts

  • Premium

Open db/ClientManagerBoot.cpp

 

bool CClientManager::InitializeLandTable()
{
	using namespace building;

under this add
 

	CDBManager::instance().DirectQuery(	"update land "
			"INNER JOIN guild ON land.guild_id = guild.id "
			"INNER JOIN player ON guild.`master` = player.id "
			"set guild_id=0 "
			"where guild_id > 0 and "
			"DATE_SUB(NOW(),INTERVAL 21 DAY) > last_play; " );
	CDBManager::instance().DirectQuery(	"DELETE object "
			"FROM object "
			"INNER JOIN land ON land.id = object.land_id "
			"WHERE land.guild_id=0; "	);

Extracted from Inception source.

  • Metin2 Dev 1
  • Sad 1
  • Love 8


 

Link to comment
Share on other sites

  • 4 years later...

Thanks for the code!

I implemented plus one more thing, the guild leader get's back the land price also when this SQL script runs down as some compensation for the loss (I don't implemented that situation when the player's gold goes higher than 2 thousand million, I don't know how to do that).
 

	CDBManager::instance().DirectQuery(	"update land "
			"INNER JOIN guild ON land.guild_id = guild.id "
			"INNER JOIN player ON guild.master = player.id "
			"set land.guild_id=0, player.gold=player.gold+land.price "
			"where land.guild_id > 0 and "
			"DATE_SUB(NOW(),INTERVAL 90 DAY) > player.last_play; " );
	CDBManager::instance().DirectQuery(	"DELETE object "
			"FROM object "
			"INNER JOIN land ON land.id = object.land_id "
			"WHERE land.guild_id=0; "	);

(My edition is not strict as yours, I let 90 day offline time for the guild masters.)

Edited by Werwolf94
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.