Convert "for" to "foreach"
#7

Quote:
Originally Posted by PrO.GameR
View Post
If you really want to turn that into a foreach loop you have to change your code structure, potentially some of those arrays (as foreach will kinda do the work of your array if it just keeps runner ids, making it useless)

A) You need to create a custom iterator and create it globally I.E: new Iterator: Runners<MAX_PLAYERS>;
B) You need to add the player ID to iterator using Iter_Add(Runners, id);
C) On approperiate parts (like /leaverun and disconnections) you need to remove them from the iterator with Iter_Remove
D) simply loop thru players running with foreach( new i : Runners)
now go and create that, and I would love for you rep hunters not to hand him what I exactly explained for him he can't rep, get the h out of this thread and let him learn some pawn.

(Hint: If you have more than 1 race runners you can create multi-dimensional Iterators which can be accessed like Runners[0]..Runners[1000], read more on this in foreach's thread)
Thanks for the great reply.
I sow the thread this morning but i had no time to read it with attention.
Tomorrow i have 4 hours to spend at the airport and maybe i can read it well..
Let you know!
Reply


Messages In This Thread
Convert "for" to "foreach" - by AaronJ - 16.06.2016, 09:09
Re: Convert "for" to "foreach" - by Nin9r - 16.06.2016, 10:09
Re: Convert "for" to "foreach" - by AaronJ - 16.06.2016, 11:01
Re: Convert "for" to "foreach" - by Nin9r - 16.06.2016, 11:08
Re: Convert "for" to "foreach" - by AaronJ - 16.06.2016, 11:48
Re: Convert "for" to "foreach" - by PrO.GameR - 16.06.2016, 17:10
Re: Convert "for" to "foreach" - by AaronJ - 16.06.2016, 18:50
Re: Convert "for" to "foreach" - by biker122 - 16.06.2016, 18:50

Forum Jump:


Users browsing this thread: 2 Guest(s)