Quote:
Originally Posted by GhostMan
Connor, all "for" cicles must be started like that
|
No they don't. A for loop requires syntax like this....
counter; condition; increment
you DO NOT need to define the counter in the header. The condition doesn't have to be related to the counter, and the increment is just a way of manipulating the data after the iteration. It is used most commonly as you have discribed, but it can be done in many different ways. It is pretty much a glorified while loop, with a counter.
Use connor's code. it relieves a native call, 3 variables, and is actually more easy to understand. This is because instead of filling an array, then starting from zero at that array and working to the end. it fills the array, takes the count of that array, and works from the top down. Also, you don't need to add your
tid = players[i] because you're only calling players once. This is just redundant in this manner. You should only use that statement when you're going to be indexing an array more than once in your loop.
EDIT: but to answer your question....v2 would be the best way OF THOSE SELECTIONS. This is because num will ALWAYS be <= maxPlayers, because its the number if ids indexed into the players array.
__________________