27.04.2015, 13:00
Is it possible to make auto delete system for inactive accounts with non-mysql accounts system?
#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;
}