05.07.2014, 04:55
here is an example
you could learn about unix timestamps here https://sampforum.blast.hk/showthread.php?tid=254915
this way may caz lag
there is one more way of doing it and that is to just do the similar thing in a php file which can be called with a timer inside game or outside game which would not caz possible lags
pawn Код:
LastLogin[MAX_PLAYERS];//on top
forward CheckLastLogin();//on top
OnPlayerDisconnect(playerid)
{
LastLogin[playerid] = gettime();
//now save variable LastLogin[playerid] into database
return 1;
}
OnGameModeInit()
{
SetTimer("CheckLastLogin",1000*60*5/*5 mins*/, true);//the timer
return 1;
}
public CheckLastLogin()
{
new var;//to store player's last login inside the loop
new store;//for calculation inside the loop
new c_time = gettime();// this is necessary now
//now here gt num of rows in players database
//run a loop line for(new i=0; i<=num_of_rows ; i++)
//now inside the loop load the LastLogin inside "var" variable
store= c_time - var;//insideloop
if(store >=(60*60*24*7)/*1 week*/)//inside loop
{
//the code to sell his stuff here
}
return 1;
}
this way may caz lag
there is one more way of doing it and that is to just do the similar thing in a php file which can be called with a timer inside game or outside game which would not caz possible lags