inactive account auto delete - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: inactive account auto delete (
/showthread.php?tid=572347)
inactive account auto delete -
aboa - 27.04.2015
Is it possible to make auto delete system for inactive accounts with non-mysql accounts system?
Re: inactive account auto delete -
Sithis - 27.04.2015
Yes.
Re: inactive account auto delete -
Adi007 - 28.04.2015
Yes, first you need to write in the files at every player login the date:
LastLoggedIn = here will be a timestamp (gettime()
pawn Код:
#define oneday 86400 // don't change that
#define afterXdays 30 //You can change this value, the max days allowed an account without login.
public OnPlayerConnect(playerid)//You can put the code from OnPlayerConnect to your login system if you want.
{
new makeSTR[100];
format(makeSTR,sizeof(makeSTR),"%i",gettime()); // Save as string because the ingeter is too big.
new file[101];
format(file, sizeof(file), "Users/%s.ini", Name);//Change to your path.
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteString(ACCOUNT, "LastSeen", LastOnlineTIMESTAMP);
INI_Close(ACCOUNT);
}
CMD:checkaccounts(playerid,params[])
{
new idx, file[MAX_FILE_NAME];
while(idx < fnum("/Users/"))
{
fname(NULL_DIR, idx, file);
format(file, 256, "/Users/%s", file);
new lastseen;
new File:handle = fopen(file, io_read),buf[100];
if(handle)
{
while(fread(handle, buf))
{
if(strfind(buf, "LastSeen", true) != -1)
{
strdel(buf, 0, 11);
lastseen = strval(buf);
}
}
if(lastseen < afterXdays*oneday) fremove (file);
if(fexist(file)) fclose(handle);
}
idx++;
}
return 1;
}
Not tested. It sould work, but if you have a lot of accounts, it would lag your server.
I used ****** (YSI) for ini files, Zeex (ZCMD) for command and Swimor(RL_FILES) from here:
https://sampforum.blast.hk/showthread.php?tid=411268