|||||||||||||||||||||||||||||||||||||||||||||||||||||||

READ THOUGH THE WHOLE TUTORIAL BEFORE YOU START

|||||||||||||||||||||||||||||||||||||||||||||||||||||||

THIS IS ALL TEXT OK? I'M LAZY, DEAL WITH IT

TL;DR? to bad

This seems like an easy thing to do, you have 3 or more math counters and want to figure out which of them is bigger then the rest. Well, with 3 it is easy, and you can probably figure it out, but once you get into 6 or more the amount of logic_compare's to compare each of them to each other one is just insane, so not only will I show you how to compare multiple math_counter's, but also what i think is the best way to do it.

First you need to know some basic logic, and that is this: if we compare math_counter #1 to math_counter #2 do we need to compare math_counter #2 to math_counter #1?

the answer is obviously no. But this is a vary important concept if your trying to save yourself some entity space.

For this tutorial, I will show you how to compare 12 math_counters, AND fire an output based on which once is the biggest

this is because, when I made this system, I made it for a map, the map had a voting system built into it, so players could choose one of the 12 "levels" within the map. the map would tally the votes (after a time) then teleport all players to the selected level. (if your curious, that map was surf_XII, i wont link to it in the tutorial, because thats not what I'm hear for.)

first off, you need your math_counters, as I said, this system will work for any amount of math counters

you are going to need two math_counters for each possible outcome. In my example, there are 12 levels the players vote for (you could use this system for something other then voting, use your imagination), so I need 24 math_counters

now, half of the math counters are the actual tally, how many votes there are for area #

the keyvalues of these will depend on what your tallying, in my example each player can only vote once, so everything is default except for the name, and the Maximum Legal Value

I'm going to use a descriptive name, "area_1_tally" this way i know exactly what the entity is for, without looking at it (or thinking about it)

for my example, the maximum legal value is "64" because servers with more then this are rare (and even 64 is rare) this will depend on what your tallying

now, you need a math_counter with the same settings as that one for each possibility, so copy and paste it, changing the name to "area_2_tally" then "area_3_tally" and so on, till you have however many you need, in my case the last one is "area_12_tally"

time for a crash course in how to use the handy entity known as logic_compare:

this entity compares two values, only two. and then fires a output, that output can be OnGreaterThen, OnEquelTo, and OnLessThen. Were only going to use the first and last possibility.

IMPORTANT!!!!!

the logic_compare compares the "Value" to the "Compare Value" this is important because if we mixed it up the outputs would be opposite what we want, we want to compare area 1 to area 2, and not the other way around

if we mixed this up, all sorts of shenanigans would ensue

the logic compares for area 1 are easy, there are 11 (there will always be 1 less logic compare for area 1 then the total # of possibility's) of them, and for now their all the same (except for name)

keyvalue : amount

name : area_1_to_area_2_compare

again, a descriptive name, i know exactly what this entity does without looking at it

thats all for now with the logic compare, make the rest of the 11, changing the second number up by 1 each time

name : area_1_to_area_3_compare

name : area_1_to_area_4_compare

...

name : area_1_to_area_12_compare

now, make a second math_counter. your going to need a duplicate math_counter for each area, might as well make them now.

keyvalue : amount

name : area_1_compare_tally (once more a descriptive name, i know what this entity does, it tally's how many of the compares output an OnGreaterThen output)

Maximum Legal Value : 11

name : area_2_compare_tally

Maximum Legal Value : 11

name : area_3_compare_tally

Maximum Legal Value : 11

...

name : area_11_compare_tally

Maximum Legal Value : 11

now, we need to add an output to each of the logic_compare's we made for area 1

OnGreaterThen : area_1_compare_tally : add : 1

once you have that in one of the entity's, hit the copy button in middle/bottom of the window

then select each other logic_compare's (either separately or at once) and hit paste

one last thing then we can work on area 2

the math_counter (area_1_tally) needs to set the value of each of the compares that start with area_1

output:

OutValue : area_1_to_area_2_compare : SetValue

OutValue : area_1_to_area_3_compare : SetValue

OutValue : area_1_to_area_4_compare : SetValue

...(their the same, you can figure it out)

OutValue : area_1_to_area_12_compare : SetValue

there will be a total of 11 outputs, thats important because each math_counter (area_#_tally) will have 11 outputs (each different of course)

so, onto area 2

you already should have its first math_counter, so we can jump to making the logic_case's for this area

now, for this area you only need 10 logic cases, and the reason is simple, we already compare area 1 to area 2 so why compare area 2 to area 1? theres no point, so one less logic compare, and we don't compare area 2 to its self, thats another one, 2 total, so area 2 will always have 2 less logic_compares then the total # of areas

the logic compares are similar to the ones for area one, just they start at

name : area_2_to_area_3_compare

name : area_2_to_area_4_compare

name : area_2_to_area_5_compare

...

name : area_2_to_area_12_compare

you already should have the math counter "area_2_compare_tally" made, so now they each just need the output:

OnGreaterThen : area_2_compare_tally : add : 1

and the math_counter "area_2_tally" needs 10 outputs:

OutValue : area_2_to_area_3_compare : SetValue

OutValue : area_2_to_area_4_compare : SetValue

OutValue : area_2_to_area_5_compare : SetValue

...

OutValue : area_2_to_area_12_compare : SetValue

but wait, thats only 10! we need 11.

well, now we start setting compare values, so one more output:

OutValue : area_1_to_area_2_compare : SetCompareValue

but theres one other problem, we only have 10 logic_compares adding to our "area_2_compare_tally" math_counter we need another one, and this is where the first areas entity's come in.

the logic_compare "area_1_to_area_2_compare" needs another output, to bring "area_2_compare_tally" to 11

so we add the output:

OnLessThen : area_2_compare_tally : add : 1

that output does the same as an OnGreaterThen output would have done were it coming from an entity comparing area 2 to area 1

now, area 3's entity's

you already should have both of the math_counters for area 3

now you just need the logic_compares

for area 3 there are 3 less logic_compare's then then total # of areas

so there are 9, make the first one, named

"area_3_to_area_4_compare"

and the output:

OnGreaterThen : area_3_compare_tally : add : 1

then copy and paste it, changing the second # in the name each time

"area_3_to_area_5_compare"

"area_3_to_area_6_compare"

...

"area_3_to_area_12_compare"

and the "area_3_tally" math_counter need to set the value of each of these logic_compares, so add the outputs:

OutValue : area_3_to_area_4_compare : SetValue

OutValue : area_3_to_area_5_compare : SetValue

...

OutValue : area_3_to_area_12_compare : SetValue

the two logic_compares that have 3 as their second # need to have their comparevalue set

so two more outputs:

OutValue : area_1_to_area_3_compare : SetCompareValue

OutValue : area_2_to_area_3_compare : SetCompareValue

and we need to add an output to both of them (the logic_compares):

OnLessThen : area_3_compare_tally : add : 1

now, the rest is just doing this over and over again, the # of logic_compares for each area can be found by subtracting that area's # from the total # of area's

and the outputs for the area_#_tally are simple, any logic_compare with that area's # first in the name, you use the SetValue, and if that areas # is second in the name you use the SetCompareValue

also note that EACH math_counter (area_#_tally) will have (the total # of areas -1) outputs (in this case, 11)

now, if you don't get what this does, it adds to a math_counter every time "area X" is greater then "area Y"

and that math_counter has a max of one less then the total # of areas, so, if area X is greater then all other areas it will hit its max, and you can fire it as an output. please note that, you still need to add to each area_#_tally (can be done many ways) and you need to set up each OnHitMax output (area_#_compare_tally)

if you guys need me to write out how to do the rest of it i will, but really you should be able to

there are only 2 other things you need:

a logic_relay with a whole lot of outputs:

OnTrigger : area_1_to_area_2_compare : Compare

OnTrigger : area_1_to_area_3_compare : Compare

OnTrigger : area_1_to_area_4_compare : Compare

...

OnTrigger : area_1_to_area_12_compare : Compare

OnTrigger : area_2_to_area_3_compare : Compare

OnTrigger : area_2_to_area_4_compare : Compare

... and so on for EVERY logic_compare

and what ever you want to happen based on which tally is the biggest

and thats all there is to it!