17.08.2011, 18:21
You can try to create player variables. You know what, I will try it for you
Add this at OnPlayerConnect(playerid)
Add this at OnPlayerUpdate
NOTE: If your server gets laggy, create a global timer with OnPlayerUpdateEx and set the time you want to update the player
Add this at OnPlayerDisconnect
Add this at OnPlayerConnect(playerid)
pawn Код:
new hour, minute, second, starts[MAX_PLAYERS][3];
printf("2-hours score has started for %d. The time currently is %02d:%02d:%02d", hour, minute, second);
starts[playerid][0] = hour;
starts[playerid][1] = minute;
starts[playerid][2] = second;
NOTE: If your server gets laggy, create a global timer with OnPlayerUpdateEx and set the time you want to update the player
pawn Код:
new hour, minute, second;
getTime(hour, minute, second));
if(hour == starts[playerid][0]+2 && minute == starts[playerid][1] && second = starts[playerid][2])
{
/* EXPLANATION FOR ABOVE
Since you want it only 2 hours. You don't need to edit the minutes or seconds because you want it once 2 hours
It just checks if the player since he connected is 2 hours long on the server
*/
SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
printf("Player %d has received an extra score for being online on the server for 2 hours. Time is %02d:%02d:%02d", getTime(hour, minute, second));
}
pawn Код:
starts[playerid][0] = 0;
starts[playerid][1] = 0;
starts[playerid][2] = 0;