I am making a little minigame, and would like to make it so people can vote for their favorite maps, please help, i also would not like it to use comparators but if it has to than ok.
i have thought of something like that but i don't know how i would detect if only one armor stand has a point, i could do it with redstone, but it is to fast for the redstone to update, i would just use a slow clock with impulse command blocks, but i want it to be fast.
Then start the vote however you intend to. The scoreboard objective I chose to use to increment when someone votes for that map is called "votes". When someone votes for the "Hell World" map you should increment that armor stand's "votes" score by 1. To better target the armor stands, you can add additional Tags like this:
Tags:["map","map01"]
Then target that armor stand with the increment command like this:
/scoreboard players add @e[tag=map01] votes 1
If you are using the /tellraw method, enable /trigger for everyone at the start only. By not re-enabling it, each player will be allowed to cast only one vote.
Once the vote has ended is when my commands take affect.
The last command I supplied is an example showing how to determine the winning map(s). As I stated, it does not care if there was more than one winner, but it will output that all of them have won.
@e[tag=map,score_votes=0,score_votes_max=0]
The above target selector will select all of the winners. If you don't care about how a tie is handled, the easiest way to pick just one would be to use @r like this:
Now in the case you need to run multiple commands on the armor stand that won, you can't really keep using @r, so here is a work around:
/scoreboard players tag @r[type=minecraft:armor_stand,tag=map,score_votes=0,score_votes_max=0] add winner
Now you can simply target the winner with @e[tag=winner].
This still doesn't exactly let you determine which map corresponds to that armor stand though, so you will need to go one step further:
/scoreboard players reset @e[tag=!winner] votes
/execute @e[tag=map01,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map01
/execute @e[tag=map02,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map02
/execute @e[tag=map03,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map03
/execute @e[tag=map04,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map04
And so on for each possible map. Only one of these commands will execute, because only the winning armor stand will exist for any of those selectors. This means if map02 won, the first /execute command will fail, the second will succeed, and the third and fourth will also fail.
After the vote has ended, remove the winner tag:
/scoreboard players tag @e[tag=winner] remove winner
Now before you start a new vote be sure to run this command before starting it:
I am making a little minigame, and would like to make it so people can vote for their favorite maps, please help, i also would not like it to use comparators but if it has to than ok.
(scoreboard objective is
VOTEMAP
1 is map 1
2 is map (etc))
Lol, this siggy was so cringe, 2013 me was cringe
i have thought of something like that but i don't know how i would detect if only one armor stand has a point, i could do it with redstone, but it is to fast for the redstone to update, i would just use a slow clock with impulse command blocks, but i want it to be fast.
Lol, this siggy was so cringe, 2013 me was cringe
Here is one way to determine which entity has the highest score:
/scoreboard players add @e[tag=map] votes 0
/scoreboard players set #placeHolder votes 0
/scoreboard players remove @e[tag=map,score_votes=0] votes 1
/execute @e[tag=map] ~ ~ ~ scoreboard players operation #placeHolder votes > @e[c=1] votes
/execute @e[tag=map] ~ ~ ~ scoreboard players operation @e[c=1] votes -= #placeHolder votes
/execute @e[tag=map,score_votes_min=0,score_votes=0] ~ ~ ~ me has been chosen!
Tag each of the armor stands with "map" and set their CustomName tag to the name of the map they represent.
This does not care if there was a tie.
How it works is by first ensuring each option exists on the scoreboard (otherwise they will be considered a winner at the end).
Creating a place holder player to store the highest score.
Eliminate any options that received no votes.
Assign the place holder's score to the highest score using the > operation.
Subtract that same score from each of the options.
Now whichever option(s) are left with a score of exactly 0 received the most votes.
i don't exactly get it, can you show it in command blocks? it might help me, also does this tell me if two maps get the exact same score?
Lol, this siggy was so cringe, 2013 me was cringe
Well you would set up your armor stands first. They should each be named after the map they represent, also they should have the "map" tag.
Example:
/summon armor_stand ~ ~ ~ {CustomName:"Hell World",Tags:["map"],Marker:1,NoGravity:1,Invulnerable:1}
Along with any other tags you may want to add.
Then start the vote however you intend to. The scoreboard objective I chose to use to increment when someone votes for that map is called "votes". When someone votes for the "Hell World" map you should increment that armor stand's "votes" score by 1. To better target the armor stands, you can add additional Tags like this:
Tags:["map","map01"]
Then target that armor stand with the increment command like this:
/scoreboard players add @e[tag=map01] votes 1
If you are using the /tellraw method, enable /trigger for everyone at the start only. By not re-enabling it, each player will be allowed to cast only one vote.
Once the vote has ended is when my commands take affect.
The last command I supplied is an example showing how to determine the winning map(s). As I stated, it does not care if there was more than one winner, but it will output that all of them have won.
@e[tag=map,score_votes=0,score_votes_max=0]
The above target selector will select all of the winners. If you don't care about how a tie is handled, the easiest way to pick just one would be to use @r like this:
@r[type=minecraft:armor_stand,tag=map,score_votes=0,score_votes_max=0]
Now in the case you need to run multiple commands on the armor stand that won, you can't really keep using @r, so here is a work around:
/scoreboard players tag @r[type=minecraft:armor_stand,tag=map,score_votes=0,score_votes_max=0] add winner
Now you can simply target the winner with @e[tag=winner].
This still doesn't exactly let you determine which map corresponds to that armor stand though, so you will need to go one step further:
/scoreboard players reset @e[tag=!winner] votes
/execute @e[tag=map01,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map01
/execute @e[tag=map02,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map02
/execute @e[tag=map03,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map03
/execute @e[tag=map04,score_votes=0,score_votes_max=0] ~ ~ ~ command to change to map04
And so on for each possible map. Only one of these commands will execute, because only the winning armor stand will exist for any of those selectors. This means if map02 won, the first /execute command will fail, the second will succeed, and the third and fourth will also fail.
After the vote has ended, remove the winner tag:
/scoreboard players tag @e[tag=winner] remove winner
Now before you start a new vote be sure to run this command before starting it:
/scoreboard players set @e[tag=map] votes 0
And you are fully reset and ready for a new vote.