Raised This Month: $ Target: $400
 0% 

Variables


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-09-2012 , 13:32   Re: Variables
Reply With Quote #4

Make an array, if you want so much these "NoScope","Normal",etc. you can make an enum.

Like:

PHP Code:
enum
{
VOTE_NOSCOPE 0,
VOTE_NORMAL,
VOTE_GRAVITY,
VOTE_VIP,
MAX_VOTES
}
 
new 
vote_options[MAX_VOTES
And then you can use:

PHP Code:
vote_options[VOTE_NOSCOPE]++ 
Or better in your case you can remove this switch and use only this:

PHP Code:
vote_options[item]++ 

The loop will be:

PHP Code:
new imax_value
for(i=0;i<4;i++) if(vote_options[i] > vote_options[max_value]) max_value 
It starts the loop at slot 0 (variable i) of the array and then checks if it's value is bigger than that's from the slot number max_value. If it's bigger, then max_value is set to i and the check continues with i = slot 1. If the value of slot 1 is bigger than the value of max_value, which is now slot 0, then set max_value to the value slot 1. Then the loop goes to slot 2 - if the value of slot 2 is bigger than that of slot 1, set max_value to the value of slot 2. At the next step i is the value of slot 3 - if the value if slot 3 is bigger than that of slot 2, set max_value to 3... and so on...

So at the end you get the highest value of the options in the array, in the max_value variable and then you can use it like this:

PHP Code:
vote_options[max_value
-> max_value is the slot of the array with the highest value.
__________________

Last edited by <VeCo>; 05-09-2012 at 13:40.
<VeCo> 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 00:28.


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