SA-MP Forums Archive
foreach next iteration - 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: foreach next iteration (/showthread.php?tid=594774)



foreach next iteration - MP2 - 22.11.2015

It is possible to find out what value is next in a foreach iteration?

For example, take the 'Player' iter, with the following IDs in:

1
5
7
8

Obviously if you did a foreach loop on this iter, you'd look through 1, 5, 8 and 9. What I need to be able to do, is find out what value comes after '5' (7). Is this at all possible? I'm talking about outside a foreach() loop.

I'm making a spectating system, and when you're spectating player ID 5, and you press the right arrow key, it needs to move on to ID 7 (next ID in the iter). I don't want to use a normal loop (MAX_PLAYERS).


Re: foreach next iteration - Jefff - 23.11.2015

I have no idea but you can try:
pawn Код:
SpectatingPlayer[playerid] = Itter_Next(Player, SpectatingPlayer[playerid]);

PlayerSpectatePlayer(playerid, SpectatingPlayer[playerid]);
and same with Itter_Prev, in my opinion simply is normal loop + GetPlayerPoolSize