Inactivity system delete player account every 2 months
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
1) Why? Is their diskspace a problem? The only reason I've heard for this is to release owner properties and vehicles but this can be done without wiping out player accounts, then if they come back they can be informed of their loss of property.

2) I'd use a CRON job to do this, not do it from PAWN directly.

3) To say more on how to do it would require far more information about your user system - currently there's nothing to go on with regards to how you even store their last login date.
Using CRON jobs would only work on Unix based systems, according to the wiki.
It looks even harder to setup a CRON job to modify data inside files, compared to setting up a timer in PAWN that runs every hour or so.

Even if you setup a CRON job to modify the data inside the userfiles to remove ownership of houses for example, you would need to reload your data after the CRON job does it's thing.
Otherwise you have data-mismatches between file-data and server-data, as the data in the server's memory doesn't get altered automatically after modifying userfiles.

After cleaning up housefiles (removing ownership), you would need to reload the house-file into your server to update the data as set in the rewritten housefile by CRON.



You could setup a timer which runs every hour.
Inside that timer, you could check every house and get the owner.
No owner -> skip the house.
Owner online -> skip the house.
For houses that don't have the owner online, read their userfile and get the last login date.

If their last login date is more than 2 months ago, remove ownership from the house in memory (set owner to nobody) and save the housefile again.
If you have stored the houseid in the userfile as well, you need to update their userfile as well.

NOTE:
If you have many houses, this will create huge lag spikes every hour.
Say you have 1200 houses and they are all occupied by players, you're looking at opening 1200 userfiles every hour, just for reading their last login date.
This will create a lag-spike of several seconds.
You can of course set the timer to run every 6 minutes and only process 1/10th of the houses every timer-iteration.
Then you only need to process 120 houses every 6 minutes.

Or run the timer every minute, then you only need to process 20 houses and load up to 20 userfiles to get their last login date.



Or you could also store the last login date of the owner directly in the housefile.
Then you don't need to load any userfile.

Then you only need to loop through every house, check the last login date of the owner and compare it to the current date.
If it's more than 2 months ago, set owner to nobody and re-save the housefile.
Since houses don't get bought often (or many at once), you're looking at re-saving only 1 or 2 housefiles every hour, or none at all.

Also, don't save any housedata in the userfile, then there is no need to open userfiles and modifying them.
When players login, you could always loop through the houses, check the owner and store the player's houseid's in the player's account (PlayerData array).

This would put the least stress of the server and it's harddrive as well, and produce the least lag.



Or transfer to using MySQL, then all you need is a well written query, which can run in the background using threaded queries.
Then you won't get ANY lag.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)