Raised This Month: $ Target: $400
 0% 

How to get the highest value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FEELiFE
Member
Join Date: Jul 2010
Old 12-04-2011 , 06:56   How to get the highest value
Reply With Quote #1

Hi guys! I need to get the highest value of a few variables. I don't like to use if because I have to compare all the values to each other and it's very clumsy.

And one more question - how can I easily check if two or more of the values are the same because there "will be two highest values" but in this case I want to chose randomly one (because the code goes wrong and no value is chosen in this case).

The values are stored in Votes[5], Votes[7], Votes[9], Votes[11], Votes[15].
FEELiFE is offline
Old 12-04-2011, 07:22
Napoleon_be
This message has been deleted by Napoleon_be.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2011 , 12:37   Re: How to get the highest value
Reply With Quote #3

Look at how vote plugins are done. They all have a loop to find the highest value. For duplicates, you can loop back through after getting the highest value and checking if there is more than one equal to the highest value.
__________________
fysiks is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-04-2011 , 13:27   Re: How to get the highest value
Reply With Quote #4

http://forums.alliedmods.net/showthr...46364#VoteMenu

Vote with menu.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
FEELiFE
Member
Join Date: Jul 2010
Old 12-04-2011 , 13:47   Re: How to get the highest value
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Look at how vote plugins are done. They all have a loop to find the highest value. For duplicates, you can loop back through after getting the highest value and checking if there is more than one equal to the highest value.
I can't find plugin with this method. More of them are the way Devil259 posted. Can you give me a example?

Quote:
Originally Posted by Devil259 View Post
I am using the same way at the moment but it is very bad when you have more than two options to compare.
FEELiFE is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2011 , 20:38   Re: How to get the highest value
Reply With Quote #6

Quote:
Originally Posted by FEELiFE View Post
I can't find plugin with this method.
Every plugin that is used as a map chooser.
__________________
fysiks is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-04-2011 , 21:45   Re: How to get the highest value
Reply With Quote #7

Look at the Advanced Vote Menu in the menu tutorial.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 12-05-2011 , 03:30   Re: How to get the highest value
Reply With Quote #8

I wanted to tell it to him aswell, but he doesn't want to do it with checks.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-05-2011 , 17:24   Re: How to get the highest value
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
I wanted to tell it to him aswell, but he doesn't want to do it with checks.
There is always going to be if statements to compare values. The key is to use a loop.
__________________
fysiks is offline
Reply



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 12:11.


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