Raised This Month: $ Target: $400
 0% 

get_players


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-14-2012 , 18:37   Re: get_players
Reply With Quote #6

Quote:
Originally Posted by GhostMan View Post
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.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 07-14-2012 at 18:39.
Liverwiz is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode