Timer not alternating between TRUE/FALSE [REP++]
#1

pawn Код:
new Clock;


forward HUDTimer();
public HUDTimer()
{
    if(Clock == 1)
        {
        Clock = 0;
        for(new i=0; i>=MAX_PLAYERS,i++;)
            {
            if(IsPlayerConnected(i) )
                {
                if(IsSpawned[i] == 1)
                    {
                   
                    TextDrawShowForPlayer(i,HUDClockBlink);
                   
                    }
                }
            }
           
       
        }
    else
        {
        TextDrawHideForAll(HUDClockBlink);
        Clock = 1;
        }

}
Reply
#2

pawn Код:
SetTimer("HUDTimer",1500,1);
OnGameModeInit


Because I can login, see the textdraw ( called onplayerspawn to show ), Watch it disappear and then never come back, I believe the timer works fine, or is just continuously looping the else.
Reply
#3

i guess the missing return 1; was th most important addition
pawn Код:
forward HUDTimer();
public HUDTimer()
{
    Clock=1-Clock;
    switch(Clock)
    {
        case 0:
        {
            for(new i=0; i>=MAX_PLAYERS,i++;)
            {
                if(IsPlayerConnected(i))
                {
                    if(IsSpawned[i] == 1)
                    {
                        TextDrawShowForPlayer(i,HUDClockBlink);
                    }
                }
            }
        }
        case 1:
        {
            TextDrawHideForAll(HUDClockBlink);
        }
    }
    return 1;
}
Reply
#4

Why use a switch for a boolean when the IF statement should work, and I humoured your return 1; theory with feeble optimistic hope, nothing changed or began working.

please clarify this too

pawn Код:
Clock=1-Clock;
Reply
#5

I did change it to

pawn Код:
<=
but yeah I still can't see where I went wrong, could you give a foreach example?
Reply
#6

pawn Код:
for(new i; i !=/*or <= if you like*/ MAX_PLAYERS; i++)
Reply
#7

What would be most efficient, foreach, while or for?
Reply
#8

foreach.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)