0

I am trying to make a voting system for difficulties in my Minecraft world. I have set up the command blocks that add the score for a fake player named #VoterDirector for each difficulty. To test if the voting works, I have set up a basic command that runs execute if score #VoterDirector Easy > #VoterDirector Normal run tellraw @a {"text":"easy wins"} The command block works successfully, but I want it to check if the Easy score is greater than all of the scores. This is where I am stuck. Adding another if score statement does not work. I have looked everywhere for a tutorial, but all of them were either outdated or Bedrock.

2 Answers 2

1

Adding another if score statement does not work.

I think it does work:

execute if score #VoterDirector Easy > #VoterDirector Normal if score #VoterDirector Easy > #VoterDirector Hard run tellraw @a {"text":"easy wins"}
execute if score #VoterDirector Normal > #VoterDirector Easy if score #VoterDirector Normal > #VoterDirector Hard run tellraw @a {"text":"normal wins"}
execute if score #VoterDirector Hard > #VoterDirector Easy if score #VoterDirector Hard > #VoterDirector Normal run tellraw @a {"text":"hard wins"}
0

An interesting question regarding checking the maximum value in Minecraft using vanilla scoreboards.

Comparing multiple scoreboard objectives end results deems not to be feasible.

Here is my plan: Setup fake players: #Max #Easy #Normal #Hard

Setup scoreboard objectives - dummy - "votes"

So that if players vote they directly add 1 value to either of the current fake players. (Except #Max)

As soon as the voting session ends, iterate through the fake players #Easy #Normal #Hard and compare their "votes" value with the #Max's "votes" value. If the value of #Max is smaller, set its "votes" value to that fake player. After that, simply iterate through all fake players again and see whose "votes" value matches exactly that of #Max's.

For example, there are 10 people on your server among which 5 voted for hard;3 voted for normal;2 voted for easy.

Let us see what would happen.

The command would go into comparing the values of #Easy and #Max. Afterwhich it would found out 2>0, obligating #Max to be changed from 0 to 2. Same thing happens when #Normal is put with #Max. Since 3>2, #Max is now 3 instead of 2. Similarly, during the last check, #Max would be 5 beacause #Hard is 5 which is bigger than 3.

After all is settled, #Max would be 5.

Iterating through all fake players, the command would discover that the value of #Hard "votes" matches 5, which is the "votes" value of #Max. Therefore, #Hard could be identified as the winner.

I believe that this is a highly effective method to find Maximum using scoreboard, since you can add a nigh-infinite number of fake players.

I have not written any commands here because I am not confident with the /data modify storage command, which is vital here. But I am sure that it can do what I mentioned above.

I hope this works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .