SetTimerEx executing too quick
#1

So, basically I have a countdown which adds 1 value to a variable, but it does too quick.. the timer is setted at 1sec.

pawn Код:
Func: MyFunc(playerid) {
    Test{playerid} ++;
    switch(Test{playerid}) {
        case 1: SendClientMessage(playerid,-1,"1");
        case 2: SendClientMessage(playerid,-1,"2");
        case 3: {
            KillTimer(E_TIMERS_ENUM[playerid][timer_Test]);
            SendClientMessage(playerid,-1,"3");
            Test{playerid} = 0;
        }
    }
    return 1;
}
pawn Код:
E_TIMERS_ENUM[playerid][timer_Test] = SetTimerEx("MyFunc", true, 1000, "i", playerid);
Reply
#2

What are you trying to do? Make it so it's slower instead of 1 second?

Also, if you mean the count down number appear all at once, then you need to add 1000 to every other second, for example:

1 - 1000
2 - 2000
3 - 3000

Code example:

Код:
SetTimer("Countdown_1", 1000, 0);
SetTimer("Countdown_2", 2000, 0);
SetTimer("Countdown_3", 3000, 0);
However, remember to forward them and make public's for them, like this:

Код:
forward Countdown_3();
Код:
public Countdown_3()
{
 	SendClientMessageEx(playerid, COLOR_WHITE, "3");
	return 1;
}
It's a different way of doing it and easier to read, also you need to do it for every single number as I did up there ^
Reply
#3

nah, that's the interval. if I test this it will print correctly (1,2,3 but very fast , ~0.1s), why?

why would I create 3 timers, wtf?

I forwarded it, np.
Reply
#4

You create 3 timers for them to interact at different times...

So:

Second 1: 1 will be printed
Second 2: 2 will be printed
Second 3: 3 will be printed
Reply
#5

or you can just repeat one timer for 3 times then kill it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)