countdown not working (only showing GO!)
#1

title says it :P

Hope somebody can help me.
pawn Код:
public StartingRace()
{
    gCountDown--;
    switch(gCountDown)
    {
    case 0:
    {
    GameTextForAll("~g~GO!", 1000, 3);
    gStarted = 1;
    KillTimer(down);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    TogglePlayerControllable(i,1);
    }
    }
    case 1: GameTextForAll("~b~1", 1000, 3);
    case 2: GameTextForAll("~y~2", 1000, 3);
    case 3: GameTextForAll("~r~3", 1000, 3);
    }
    return 1;
}
Reply
#2

pawn Код:
gCountDown=3;
StartingRace();
Maybe the var isn't set to 3 when the countdown starts.
Reply
#3

it is :S
Reply
#4

pawn Код:
public StartingRace()
{
    gCountDown--;
    if(gCountDown == 0)
    {
        GameTextForAll("~g~GO!", 1000, 3);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            TogglePlayerControllable(i,true);
        }
        return 1;
    }
    if(gCountDown == 3)
    {
        GameTextForAll("~r~3",1000,3);
        return 1;
    }
    if(gCountDown == 2)
    {
        GameTextForAll("~y~2",1000,3);
        return 1;
    }
    if(gCountDown == 1)
    {
        GameTextForAll("~b~1",1000,3);
            return 1;
    }
    return 1;
}
Longer,but try this,and you need to set the variable to 4,not 3 since firstly you're subtracting 1 from the variable size,and only then checking if it equals to 3,but it equals to 2..
Reply
#5

pawn Код:
public StartingRace()
{
    new string[6];
    gCountDown--;
    if(gCountDown == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                TogglePlayerControllable(i,1);
            }
        }
        GameTextForAll("~g~GO!", 1000, 3);
        gStarted = 1;
        KillTimer(down);
    }
    else
    {
        format(string,sizeof(string),"~y~%d",gCountDown);
        GameTextForAll(string,2000,3);
    }
    return 1;
}
Reply
#6

I changed my code to: 4 and it's working fine now, ty.

now i got a other problem:
Код:
error 002: only a single statement (or expression) can follow each "case"
pawn Код:
case 1: GameTextForAll("~b~1", 1000, 3); { PlaySoundForAll(1056); }
case 2: GameTextForAll("~y~2", 1000, 3); { PlaySoundForAll(1056); }
case 3: GameTextForAll("~r~3", 1000, 3); { PlaySoundForAll(1056); }
Reply
#7

Quote:
Originally Posted by LifeStyle
Посмотреть сообщение
I changed my code to: 4 and it's working fine now, ty.
Simple maths :P

And as for your errors:
pawn Код:
case 1: {GameTextForAll("~b~1", 1000, 3);  PlaySoundForAll(1056); }
case 2: {GameTextForAll("~y~2", 1000, 3); PlaySoundForAll(1056); }
case 3: {GameTextForAll("~r~3", 1000, 3);  PlaySoundForAll(1056); }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)