10.05.2007, 21:44
2 loops in 1
This lets you do the same thing 2 loops would do, except in only 1 loop, and both the loops have a different number of loops to do.
MAX_PLAYERS = 100.
MAX_BLAH = 50.
So that will only use 1 loop but can change arrays of different lengths.
Its more effecient then:
You can also do it for any amount of loops you want.
This lets you do the same thing 2 loops would do, except in only 1 loop, and both the loops have a different number of loops to do.
MAX_PLAYERS = 100.
MAX_BLAH = 50.
pawn Код:
new i;
while((i < MAX_BLAH) || (i < MAX_PLAYERS)) // smaller the MAX_BLAH or MAX_PLAYERS
{
if(i < MAX_BLAH) Something[i] = 0; // if i is smaller then MAX_BLAH only
if(i < MAX_PLAYERS) Other[i] = false; // if i is smaller then MAX_PLAYERS only
i++; // increase i to do next loop(s)
}
Its more effecient then:
pawn Код:
for(new i; i < MAX_PLAYERS; i++) Other[i] = false;
for(new i; i < MAX_BLAH; i++) Something[i] = 0;
pawn Код:
while((i < MAX_BLAH) || (i < MAX_PLAYERS) || (i < MAX_PIE))
{
if(i < MAX_BLAH) Something[i] = 0;
if(i < MAX_PLAYERS) Other[i] = false;
if(i < MAX_PIE) pies -= 90;
i++;
}