Avoiding specific function from loop
#1

Is there a way i could avoid a textdraw and at the same time using a loop to show the other textdraws?
I have 15 textdraws and i want in some times showing the 13 or 14 or 12 of it is there a way to use loop and at the same time avoid one or 2 textdraws?
pawn Код:
new Text:AnimList[16];
Reply
#2

I've only been able to test this in the console:


//This example will show all textdraws, except 12 and 14. You can add as many parameters as you want.
pawn Код:
ShowAnimList(playerid, 12, 14);
pawn Код:
stock ShowAnimList(playerid, ...)
{
    new arg = numargs(), bool:proceed;
    for(new i; i<sizeof(AnimList); i++)
    {
        proceed = true;
        for(new j=1; j<(arg); j++)
        {
            if(getarg(j) == i) proceed = false;
        }
        if(proceed == true) TextDrawShowForPlayer(playerid, AnimList[i]);
    }
    return 1;
}
Reply
#3

Just use conditional checks and the "continue" keyword, which skips to the next iteration.

pawn Код:
for (new i = 0; i < 16; i ++)
{
    if (i == 13 || i == 14)
    {
        // Textdraw 13 and 14 will not be shown.
        continue;
    }
    else
    {
        TextDrawShowForPlayer(playerid, AnimList[i]);
    }
}
Reply
#4

pawn Код:
example(playerid)
{
    for(new i = 0; i < 16; i ++)
    {
        if(i != 12 && i != 14)
        {
            TextDrawShowForPlayer(playerid, AnimList[i]);
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)