Multiple timers
#1

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?
Reply
#2

It's either timers, or a OneSecondTimer and create variables.
Reply
#3

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
}
...
Reply
#4

Quote:
Originally Posted by Vanter
Посмотреть сообщение
It's either timers, or a OneSecondTimer and create variables.
Quote:
Originally Posted by doreto
Посмотреть сообщение
Varibles

Editing ...
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!
Reply
#5

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;
            }
     }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)