SA-MP Forums Archive
Question Info Function: break - 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)
+--- Thread: Question Info Function: break (/showthread.php?tid=357297)



Question Info Function: break - Speed++ - 06.07.2012

Hello,

can explain me the function
PHP код:
break 
?

this function block / stop the loop ?


Re: Question Info Function: break - Jason` - 06.07.2012

pawn Код:
public OnFilterScriptInit()
{
    for(new i = 0; i < 100; ++i)
    {
        printf("%i", i);
        if(i == 50)
        {
            break;
        }
    }
    return 1;
}
Will print: 0 1 2 3 4 5 6 ... 50
When i = 50, will stop the loop.

Understand?


Re: Question Info Function: break - Libra_PL - 06.07.2012

Or in other words - function "break;" stops the loop anytime you want before it finishes.

EDIT: I didn't see one sentence of poster above.


Re: Question Info Function: break - Speed++ - 06.07.2012

Quote:
Originally Posted by Pedro_Miranda
Посмотреть сообщение
pawn Код:
public OnFilterScriptInit()
{
    for(new i = 0; i < 100; ++i)
    {
        printf("%i", i);
        if(i == 50)
        {
            break;
        }
    }
    return 1;
}
Will print: 0 1 2 3 4 5 6 ... 50
When i = 50, will stop the loop.

Understand?
yes, thanks

Thanks all.