Avoiding specific function from 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)
+--- Thread: Avoiding specific function from loop (
/showthread.php?tid=560861)
Avoiding specific function from loop -
vassilis - 30.01.2015
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?
Re: Avoiding specific function from loop -
Schneider - 30.01.2015
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;
}
Re: Avoiding specific function from loop - Emmet_ - 30.01.2015
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]);
}
}
Re: Avoiding specific function from loop -
SickAttack - 30.01.2015
pawn Код:
example(playerid)
{
for(new i = 0; i < 16; i ++)
{
if(i != 12 && i != 14)
{
TextDrawShowForPlayer(playerid, AnimList[i]);
}
}
}