Jump to content
  • 0

Doubt delete char automatically


Jamy

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  54
  • Reputation:   0
  • Joined:  02/14/12
  • Last Seen:  

How do I get the inactive accounts more than 1 year are deleted automatically.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  213
  • Reputation:   109
  • Joined:  05/21/12
  • Last Seen:  

Use at your own risk:

# Delete cart storage
DELETE FROM `cart_inventory`
WHERE EXISTS
 ( SELECT `char`.`char_id`
    FROM `char`
    RIGHT JOIN `login`
    ON `login`.`account_id` = `char`.`account_id`
    WHERE `cart_inventory`.`char_id` = `char`.`char_id`
    AND `login`.`lastlogin` < DATE_ADD(CURDATE(), INTERVAL -1 YEAR));

# Delete storage
DELETE FROM `storage`
WHERE EXISTS
 ( SELECT `login`.`account_id`
    FROM `login`
    WHERE `storage`.`account_id` = `login`.`account_id`
    AND `login`.`lastlogin` < DATE_ADD(CURDATE(), INTERVAL -1 YEAR));

# Delete inventories
DELETE FROM `inventory`
WHERE EXISTS
 ( SELECT `char`.`char_id`
    FROM `char`
    RIGHT JOIN `login`
    ON `login`.`account_id` = `char`.`account_id`
    WHERE `inventory`.char_id = `char`.`account_id`
    AND `login`.`lastlogin` < DATE_ADD(CURDATE(), INTERVAL -1 YEAR));

# Delete characters
DELETE FROM `char`
WHERE EXISTS
 ( SELECT `login`.`account_id`
    FROM `login`
    WHERE `login`.account_id = `char`.`account_id`
    AND `login`.`lastlogin` < DATE_ADD(CURDATE(), INTERVAL -1 YEAR));

# Delete accounts
DELETE FROM `login`  WHERE `lastlogin` < DATE_ADD(CURDATE(), INTERVAL -1 YEAR);

I wrote these queries up. Use at your own risk. Probably could do skills, variables and other junk, too. Let me know.

Edit:

Set-up a cronjob if using linux daily. Have it execute queries via mysql. Being admin that has hundreds of players online, I wouldn't suggest this at all unless the server is completely offline. That's just me - this could cause serious latency and issues. Let's say, for example, the player logs in while it's running... Yikes, lol.

Edited by Cookie
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  54
  • Reputation:   0
  • Joined:  02/14/12
  • Last Seen:  

Thanks Cookie, it worked.

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.

Guest
Answer this question...

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