Jump to content

[Share]Clean Tables


Recommended Posts

 

Delete characters with level 20(or less) and 2 months of inactive

DELETE FROM character_friends WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_subclasses WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_hennas WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_macroses WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_quests WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_recipebook WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_shortcuts WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_skills WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_skills_save WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM character_subclasses WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM items WHERE owner_id in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20);
DELETE FROM characters WHERE lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(51840000))*1000) and accesslevel<=0 and level<=20;

 

Delete banned accounts

UPDATE characters SET `accesslevel` = '-99' where account_name in (select login from accounts WHERE `accessLevel` < 0) AND account_name NOT IN (SELECT `account` FROM `l2_bannedontime`);
DELETE FROM character_friends WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel < 0);
DELETE FROM character_subclasses WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_hennas WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_macroses WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_quests WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_recipebook WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_shortcuts WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_skills WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_skills_save WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM character_subclasses WHERE charId in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM items WHERE owner_id in (select charId from characters where lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0);
DELETE FROM characters WHERE lastaccess<((UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-(30*24*3600))*1000) and accesslevel<0;

Link to comment
Share on other sites

Thanks for share, but I'll pass.

only the first is good. the second is useless . why? because maybe you want to give second chance to banned members or they pay to get unbanned ..!

anyway thnx

 

+

Link to comment
Share on other sites

  • 3 months later...

This is ok but I think there will be errors with the items. I mean these characters that are deleted own some items so there will be errors in the gameserver (i think).

 

The same happens if you delete NPC's without deleting their spawns.

Link to comment
Share on other sites

This is ok but I think there will be errors with the items. I mean these characters that are deleted own some items so there will be errors in the gameserver (i think).

 

The same happens if you delete NPC's without deleting their spawns.

 

Wrong, when you delete a character from the database everything associated with it will be deleted from the database next time you reboot the server. L2j cores were written to check the player ID's against the other tables, when it does not find an active one it removes it from the database.

 

On some if you watch the server starting up you will see something like "X Items cleaned from database." or something like that.

 

Deleting NPC's is not the same as deleting characters, NPC's have set ID's that the server needs when loading. If you delete an NPC from the NPC table then yes, you will have problems as many NPC's have their own skill lists, drops, html texts, etc.

 

As for the script to delete banned character I think it a bad idea as a players can once again create the same character. However if you do this and then restart the server then anything associated with the deleted character(s) will be deleted upon server load so even if they make the same character they will start from scratch (or however you have your server set).

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.



×
×
  • Create New...