Help on a cmd
#3

Basically you create a variable to hold login data (i.e LastLogin=day/month/year), save this variable for player into a file or your database (depends how you're dealing with accounts and other stuff) and update that variable everytime they log in/off. Here's some code from some mode I'd been working on, it should help you out:

pawn Код:
COMMAND:clearunusedaccounts(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
    {
        return Error(playerid, "You are not logged into rcon!");
    }
    new mnth, yr;
    if(sscanf(params, "ii", mnth, yr))
    {
        return MessageBox(playerid, "~r~~h~~h~USAGE", "/clearunusedaccounts <month> <year>");
    }
    new days;
    if(IsMonth31(mnth))
        days = 31;
    else if(mnth == 2 && IsMonth29(yr))
        days = 29;
    else if(mnth == 2 && !IsMonth29(yr))
        days = 28;
    else
        days = 30;
    for(new i = 0; i < days; i++)
    {
        mysql_query(sprintf("DELETE FROM players WHERE LastOn='%d/%d/%d'", i, mnth, yr));
    }
    return 1;
}

// OnLoggedIn
new tmpip[64],day,month,year;
getdate(year,month,day);
format(tmpip,sizeof tmpip,"%d/%d/%d",day,month,year);
format(PData[playerid][laston], 64, "%s", tmpip);
Reply


Messages In This Thread
Help on a cmd - by Driver546465 - 28.04.2015, 20:28
Re: Help on a cmd - by Driver546465 - 28.04.2015, 20:38
Re: Help on a cmd - by [KHK]Khalid - 28.04.2015, 21:04
Re: Help on a cmd - by Driver546465 - 28.04.2015, 21:13
Re: Help on a cmd - by [KHK]Khalid - 28.04.2015, 21:16
Re: Help on a cmd - by Driver546465 - 28.04.2015, 21:18
Re: Help on a cmd - by Driver546465 - 28.04.2015, 21:21
Re: Help on a cmd - by [KHK]Khalid - 28.04.2015, 21:24
Re: Help on a cmd - by Driver546465 - 28.04.2015, 21:27

Forum Jump:


Users browsing this thread: 1 Guest(s)