[Ajuda] Loop - 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] Loop (
/showthread.php?tid=372710)
Loop -
DrTHE - 27.08.2012
pawn Код:
Teste(playerid)
{
for(new x; x < 5; ++x)
{
if(strcmp(Clan[x], "Nenhum", true) != 0) continue;
{
new teste[128];
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
}
}
Como fazer para caso se
nenhuma "if" seja chamada no loop retornar a uma mensagem de erro?
Espero que alguma alma me ajude
Re: Loop -
WeenSoares_ - 27.08.2012
Nгo entendi muito bem, mais acho que nгo deveria por um "
else" ?
Re: Loop -
Victor' - 27.08.2012
pawn Код:
Teste(playerid)
{
for(new x; x < 5; ++x)
{
if(strcmp(Clan[x], "Nenhum", true) != 0) SendClientMessage(playerid, -1, "Erro");
{
new teste[128];
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
}
}
Re: Loop -
Kmatsu - 28.08.2012
assim?
pawn Код:
Teste(playerid)
{
for(new x; x < 5; ++x)
{
if(!strcmp(Clan[x], "Nenhum", true))
{
new teste[128];
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
if(x == 4) //ULTIMO numero do loop
MsgToPlayer("ERROR: Nada liberado '-'");
}
}
Re: Loop -
jpeg - 28.08.2012
pawn Код:
Teste(playerid)
{
for(new x; x < 5; ++x)
{
if(strcmp(Clan[x], "Nenhum", true) != 0) continue;
{
new teste[128];
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
}
else
{
SendClientMessage(playerid, -1, "Erro");
}
}
Re: Loop -
Joker_OutLock - 28.08.2012
pawn Код:
Teste(playerid)
{
for(new x; x < 5; ++x)
{
if(strcmp(Clan[x], "Nenhum", true) == 0) break;
new teste[128];
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
}
Re: Loop -
[JD]BlackFire - 28.08.2012
else em loop? #failmaster
Re: Loop -
Kmatsu - 28.08.2012
Else em loop?
Vocкs estгo testando as porcarias que postam aqui?
Re: Loop -
jpeg - 28.08.2012
#correto:
pawn Код:
Teste(playerid)
{
for(new x; x < 5; ++x)
{
new teste[128];
if(strcmp(Clan[x], "Nenhum", true) != 0) continue;
{
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
else
{
format(teste, sizeof(teste), "Msg de erro para o player");
MsgToPlayer(teste);
}
}
}
Re: Loop -
paulor - 28.08.2012
pawn Код:
Teste(playerid)
{
new bool: PtLib = true;
for(new x; x < 5; ++x)
{
if(strcmp(Clan[x], "Nenhum", true) != 0) continue;
{
PtLib = false;
new teste[128];
format(teste, sizeof(teste), "Slot clan %d liberado", x);
MsgToPlayer(teste);
break;
}
}
if(PtLib) //Erro
}