countdown not working (only showing GO!) - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: countdown not working (only showing GO!) (
/showthread.php?tid=171103)
countdown not working (only showing GO!) -
LifeStyle - 25.08.2010
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;
}
Re: countdown not working (only showing GO!) -
Rac3r - 25.08.2010
pawn Код:
gCountDown=3;
StartingRace();
Maybe the var isn't set to 3 when the countdown starts.
Re: countdown not working (only showing GO!) -
LifeStyle - 25.08.2010
it is :S
Re: countdown not working (only showing GO!) -
[XST]O_x - 25.08.2010
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..
Re: countdown not working (only showing GO!) -
Voldemort - 25.08.2010
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;
}
Re: countdown not working (only showing GO!) -
LifeStyle - 25.08.2010
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); }
Re: countdown not working (only showing GO!) -
[XST]O_x - 25.08.2010
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); }