AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get the highest value (https://forums.alliedmods.net/showthread.php?t=173370)

FEELiFE 12-04-2011 06:56

How to get the highest value
 
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].

fysiks 12-04-2011 12:37

Re: How to get the highest value
 
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.

Devil259 12-04-2011 13:27

Re: How to get the highest value
 
http://forums.alliedmods.net/showthr...46364#VoteMenu

Vote with menu.

FEELiFE 12-04-2011 13:47

Re: How to get the highest value
 
Quote:

Originally Posted by fysiks (Post 1607709)
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 (Post 1607744)

I am using the same way at the moment but it is very bad when you have more than two options to compare.

fysiks 12-04-2011 20:38

Re: How to get the highest value
 
Quote:

Originally Posted by FEELiFE (Post 1607755)
I can't find plugin with this method.

Every plugin that is used as a map chooser.

Emp` 12-04-2011 21:45

Re: How to get the highest value
 
Look at the Advanced Vote Menu in the menu tutorial.

Napoleon_be 12-05-2011 03:30

Re: How to get the highest value
 
I wanted to tell it to him aswell, but he doesn't want to do it with checks.

fysiks 12-05-2011 17:24

Re: How to get the highest value
 
Quote:

Originally Posted by Napoleon_be (Post 1608015)
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.


All times are GMT -4. The time now is 12:11.

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