Backwards loop problem
#1

So this piece of code can go below all the way to 0. I want it so that if it goes below 0, it starts again from MAX_ARENAS which is set to 100. Now, arena 100 to 30 don't exist, so then the loop should start at 29. BUT, its stuck at 0. Won't start at MAX_ARENAS and skip the ones that don't exist.

pawn Код:
for(new i = PVar[playerid][Test] - 1; i >= -1; i--)
{
    if(i == -1) i = MAX_ARENAS; // i should now be 100.

    if(gArena[i][aExists] == false) continue; // this should skip from 100 to 30.

    PVar[playerid][Test] = i; // this should be 29
    break;
}
Reply
#2

why you have used break since it will stop the loop after running for 1 time
Reply
#3

Quote:
Originally Posted by Danyal
Посмотреть сообщение
why you have used break since it will stop the loop after running for 1 time
Where should I place break then? I've tried shit load of combinations and nothing is working so far.
Reply
#4

try removing break and check
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)