How to stop a loop ? - 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: How to stop a loop ? (
/showthread.php?tid=135682)
How to stop a loop ? -
Zeromanster - 21.03.2010
So here's an example:
pawn Код:
for(new i = 0; i < 5; i++)
{
if(something[i] == 0)
{
dosomething;
}
else
{
error;
}
}
So i want to stop the loop when the array equals to zero, and if the loop reaches it end and didn't find an array equaled to zero, then display the error message...
I can't seem to stop it, so please help, thank you.
Re: How to stop a loop ? -
Zeromanster - 21.03.2010
BUMP. I really need this quick...
Re: How to stop a loop ? -
Jefff - 21.03.2010
Just use break;
Код:
for(new i = 0; i < 5; i++)
{
if(something[i] == 0)
{
dosomething;
break;
}
else
{
error;
}
}
Re: How to stop a loop ? -
Zeromanster - 21.03.2010
Quote:
Originally Posted by Jefff
Just use break;
Код:
for(new i = 0; i < 5; i++)
{
if(something[i] == 0)
{
dosomething;
break;
}
else
{
error;
}
}
|
I tryed that, and i tryed using return 1; , both of them don't work and the loop executes the else and continues on..
Re: How to stop a loop ? -
deltaRPG - 21.03.2010
try continue;
Re: How to stop a loop ? -
Zeromanster - 21.03.2010
Doesn't work either.
Re: How to stop a loop ? -
dice7 - 21.03.2010
break; stops the loop, continue; stops the literation and continues from the start of the loop. You're doing something wrong