28.04.2015, 21:04
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);