Multiple timers - 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: Multiple timers (
/showthread.php?tid=459970)
Multiple timers -
RajatPawar - 25.08.2013
Hi, how would you approach this?
Tasks to do:
1) TASK 1: Show text1
2) TASK 2: Hide text1 and show text2 after 3 secs
3) TASK 3: Hide text2 and show text1 after 3 secs
Kind of a loop. The worst way possible is setting timers to and fro
ShowText1
{
Showtext2 && SetTimer for TASK 2
}
ShowText2
{
Showtext3 && SetTimer for TASK 1
}
I admit it can be done using timers and killing them, etc, but is there an efficient way?
Re: Multiple timers -
Vanter - 25.08.2013
It's either timers, or a OneSecondTimer and create variables.
Re: Multiple timers -
doreto - 25.08.2013
Varibles
Create one timer or use exist if you have already, set varible to +1 and after 3 seconds check if varible is same as you wont to show on that...
pawn Код:
if(varible == 1)
{
hide text 0 & show text 1
varible +1
}
else if(varible == 2)
{
hide text 1 & show text 2
varible +1
}
...
Re: Multiple timers -
RajatPawar - 25.08.2013
Quote:
Originally Posted by Vanter
It's either timers, or a OneSecondTimer and create variables.
|
Quote:
Originally Posted by doreto
|
Quote:
Originally Posted by Rajat_Pawar
I admit it can be done using timers and killing them, etc, but is there an efficient/better way?
|
It's confusing and bad having to use timers and interloop them, it could easily cause infinite loops if not handled correctly. I was merely asking for alternatives!
Re: Multiple timers -
ProjectMan - 25.08.2013
Somewhere outside:
pawn Код:
new TextTimer;
new TextTimerQueue;
OnGameModeInit:
pawn Код:
TextTimer = SetTimer("TextShow", 3000, true);
Somewhere outside:
pawn Код:
forward TextShow();
public TextShow()
{
TextTimerQueue++;
switch (TextTimerQueue)
{
case 1: //3 secs passed
{
HideText3 //Your code
ShowText1 // Your code
}
case 2: //6 secs passed
{
HideText1 // Your code
ShowText2 //Your code
}
case 3: //9 secs passed
{
HideText2 //Your code
ShowText3 //Your code
TextTimerQueue = 0;
}
}
}