Inactivity system delete player account every 2 months
#1

How to make inactivity system who detect player last time on server,and if player not on server 2 months script delete his account or something else from users.ini file..
Reply
#2

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.
Yes but can you give me some example how i can make 1st
Reply
#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
#4

I will make mysql in future, i think the problem was fixed if i install mysql plugin..
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
The cron job suggestion was just a suggestion based on my other point - that there was no information on HOW the house system is set up. Your suggestion on how to do it while shooting down the alternates makes huge assumptions about how the code is written, assumptions that you simply can't make. To say that my idea would not work while yours would is at the very least misleading. IF all the house data is in one file and IF it is all loaded in to memory at once, then your idea will work better, but despite me requesting additional code there is no evidence either way.
If you want to know i use ravens gamemode,and you probbably know ravens house system.
It's possible to make it
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
The cron job suggestion was just a suggestion based on my other point - that there was no information on HOW the house system is set up. Your suggestion on how to do it while shooting down the alternates makes huge assumptions about how the code is written, assumptions that you simply can't make. To say that my idea would not work while yours would is at the very least misleading. IF all the house data is in one file and IF it is all loaded in to memory at once, then your idea will work better, but despite me requesting additional code there is no evidence either way.
I didn't mean any offense or break down your suggestions.

But as he stated he uses users.ini file, it was pretty clear he's using files.
Since SAMP by default doesn't allow browsing directories, files must be read when a user connects.

Even if the house-file holds all houses at once, or only 1 house per file, using any system that modifies files in the background, you always need to reloaded the files for those changes to take effect in the script/server memory.

Most housing systems also place the icons/pickups/3DTexts for every house on the map when the server starts, so house-files are read during OnGameModeInit and are never re-loaded (except for house-vehicles during OnPlayerConnect probably as I did in mine), only re-saved when changes are made.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)