27.08.2012, 14:52
Hello.
This function works, after some time however, the numbers start skipping and does not function like it should.
What I'm trying to do is use this function to display the amount of time people have been logged in the server, therefore the reason why I added the variables, in which can be then seen in the stats command.
It works, but like I said, after a while, they start going crazy..
The timer is active once the player connects..
The timer is destroyed, to avoid any lapses..
pawn Код:
forward OneSecondUpdate(playerid);
public OneSecondUpdate(playerid)
{
if(PlayerInfo[playerid][pSeconds] == 59)
{
PlayerInfo[playerid][pSeconds] = 0;
if(PlayerInfo[playerid][pMinutes] == 59)
{
PlayerInfo[playerid][pMinutes] = 0;
if(PlayerInfo[playerid][pHours] == 23)
{
PlayerInfo[playerid][pHours] = 0;
PlayerInfo[playerid][pDays]++;
}
else PlayerInfo[playerid][pHours]++;
}
else PlayerInfo[playerid][pMinutes]++;
}
else PlayerInfo[playerid][pSeconds]++;
return 1;
}
What I'm trying to do is use this function to display the amount of time people have been logged in the server, therefore the reason why I added the variables, in which can be then seen in the stats command.
It works, but like I said, after a while, they start going crazy..
pawn Код:
OnPlayerConnect(playerid);
{
OneSecondUpdatetimer = SetTimerEx("OneSecondUpdate",1000,true,"iiii",playerid);
return 1;
}
pawn Код:
OnPlayerDisconect(playerid);
{
KillTimer(OneSecondUpdatetimer);
return 1;
}