SA-MP Forums Archive
Timer working too fast - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Timer working too fast (/showthread.php?tid=658138)



Timer working too fast - ,TomY' - 24.08.2018

I dont know why, but my timer working too fast. I used printf to check, how it works. Timer must check every 1 second and if player is in same position, system should add AFKTIME 1 every second. When I watching samp-server.exe I see ( printfs ) that AFKTIME adding +1 not every second, but every ~0.3-0.5 sec ( very fast ).

Timer starts when player connect:
Код:
SetTimerEx("UpdatePlayer", 1000, true, "d", playerid);
Код:
forward UpdatePlayer(playerid);
public UpdatePlayer(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, PAFK[playerid][3],PAFK[playerid][4],PAFK[playerid][5]))
{
    AFKTIME[playerid] ++,printf("AFK %i",AFKTIME[playerid]);
    if(AFKTIME[playerid] > 20){pInfo[playerid][afk]=1;}
}
else AFKTIME[playerid] = 0,pInfo[playerid][afk]=0,GetPlayerPos(playerid,PAFK[playerid][3],PAFK[playerid][4],PAFK[playerid][5]);
     return 1;
}