Conflicting Timers
#1

Okay, I ran into a Timer problem when they are self-recursive, I made this once I suspected the problem.

pawn Код:
OnGameModeInit()
{
SetTimerEx("testing", 1000, 0, "s", "woot");
SetTimerEx("testing", 500, 0, "s", "hehe");
return 1;
}

foward testing(string[])
public testing(string[])
{
print(string);
SetTimerEx("testing", 1000, 0, "s", string);
return 1;
}
excuse the indentation, I guess I have deleted my function.
well, that would print a (null) and then restart my server, so i changed it to.
pawn Код:
foward testing(string[])
public testing(string[])
{
new string2[1000];
format(string2, sizeof(string2), "%s", string);
print(string2);
SetTimerEx("testing", 1000, 0, "s", string2);
return 1;
}
and that would print hehe only. it wouldn't print any woot's.

why? I have no clue. but i definitely need help.
Reply
#2

Still causing me head-aches.
Reply
#3

I ran
pawn Код:
main()
{
    SetTimerEx("testing", 500, 0, "s", "woot");
    SetTimerEx("lolcat", 1000, 0, "s", "hehe");
}

forward testing(string[])
public testing(string[])
{
    new coolstring[100];
    format(coolstring, sizeof(coolstring), "%s", string);
    printf("%s &", coolstring);
    SetTimerEx("lolcat", 1000, 0, "s", coolstring);
    return 1;
}

forward lolcat(string[])
public lolcat(string[])
{
    new coolstring[100];
    format(coolstring, sizeof(coolstring), "%s", string);
    printf("%s &&", coolstring);
    SetTimerEx("testing", 1000, 0, "s", coolstring);
    return 1;
}
and it prints
woot &&
woot &
woot &
woot &&
woot &&
woot &
woot &
woot &&
...
this puzzles me deeply, since the first time lolcat() get's called is with the direct quote "hehe" yet it shows "woot", I am so confused.
Reply
#4

That is a bug of SetTimerEx, you can't fix it, but you can avoid that bug by not running a SetTimerEx if another is already running.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)