SA-MP Forums Archive
Backwards loop problem - 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: Backwards loop problem (/showthread.php?tid=466415)



Backwards loop problem - -Prodigy- - 27.09.2013

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;
}



Re: Backwards loop problem - Danyal - 27.09.2013

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


Re: Backwards loop problem - -Prodigy- - 27.09.2013

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.


Re: Backwards loop problem - Danyal - 27.09.2013

try removing break and check