SA-MP Forums Archive
SetTimerEx executing too quick - 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: SetTimerEx executing too quick (/showthread.php?tid=453632)



SetTimerEx executing too quick - fordawinzz - 25.07.2013

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);



Re: SetTimerEx executing too quick - Kebab- - 25.07.2013

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 ^


Re: SetTimerEx executing too quick - fordawinzz - 25.07.2013

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.


Re: SetTimerEx executing too quick - Kebab- - 25.07.2013

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


Re: SetTimerEx executing too quick - fordawinzz - 25.07.2013

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