14.06.2010, 20:02
Basically, I have a command and all it has in it is a variable and a SetTimerEx. In the callback that the timer is calling it reduces the variable each second until it = 0 then it kills the timer for the player. It works as it should if the command is only used once, however if the player spams the command twice, the timer will never kill, and it keeps repeating the Test callback.. Has anyone else ever had this problem with SetTimerEx?
This above, if you use the command while its still counting down from the last time you used the command, the timer will never kill and it will just keep sending the "TEST: Timer Killed" message..
Is this a known problem with the function, or am I completely looking over something?
pawn Код:
forward Test(playerid);
new testtimer[MAX_PLAYERS];
new TestStuff[MAX_PLAYERS];
pawn Код:
public Test(playerid)
{
if(TestStuff[playerid] >= 1)
{
TestStuff[playerid] -= 1;
new teststring[128];
format(teststring,sizeof(teststring),"TEST: (%i) Stuffs Remaining", TestStuff[playerid]);
SendClientMessage(playerid,COLOR_RED,teststring);
return 1;
}
else
{
KillTimer(testtimer[playerid]);
SendClientMessage(playerid,COLOR_YELLOW,"TEST: Timer Killed");
return 1;
}
}
pawn Код:
if (strcmp("/test", cmdtext, true, 5) == 0)
{
testtimer[playerid] = SetTimerEx("Test",2000,1,"i",playerid);
TestStuff[playerid] += 5;
return 1;
}
Is this a known problem with the function, or am I completely looking over something?