SA-MP Forums Archive
[Ajuda] Erro switch - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Erro switch (/showthread.php?tid=644006)



Erro switch - Marllun - 01.11.2017

Estou tentando fazer sу que dar erro

Код:
forward InicioCorrida();


public InicioCorrida()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
case:1
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "5", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
case:2
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "4", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
case:3
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "4", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
case:4
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "3", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
case:5
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "2", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
case:6
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "1", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
case:7
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "GO", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
}
}
}
}



Re: Erro switch - C4rtm4n - 01.11.2017

Vocк esta usando switch de forma errada.

https://sampforum.blast.hk/showthread.php?tid=240470


Re: Erro switch - DelK - 01.11.2017

@edit
Jб vi o erro, se ajudei um rep faz bem kk.
PHP код:
forward InicioCorrida();
public 
InicioCorrida()
{
    for(new 
0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            case 
0:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"5"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            case 
1:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"4"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            
SetTimer("InicioCorrida3"1000false);
            case 
2:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"4"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            
SetTimer("InicioCorrida3"1000false);
            case 
3:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"3"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            
SetTimer("InicioCorrida3"1000false);
            case 
4:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"2"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            
SetTimer("InicioCorrida3"1000false);
            case 
5:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"1"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            
SetTimer("InicioCorrida3"1000false);
            case 
6:
            {
                if(
correndo[i] == 1)
                {
                    
GameTextForPlayer(i"GO"10015);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
            
SetTimer("InicioCorrida3"1000false);
        }
    }
    return 
1;




Re: Erro switch - IlanZ - 02.11.2017

Falta o switch.

PHP код:
switch(variavel//por exemplo 



Re: Erro switch - MrEdu - 02.11.2017

Enfim, que variбvel vocк quer aplicar o switch?
Код:
new variavel;
switch(variavel)



Re: Erro switch - Marllun - 02.11.2017

Obrigado