inactive account auto delete
#1

Is it possible to make auto delete system for inactive accounts with non-mysql accounts system?
Reply
#2

Yes.
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: