Hello, I am trying to make a voting system. The vote is open for 2 minutes, the result is announced after this time. The player who has been voted the most receives a private message.
I do not know how detect the person who has received the most votes.
I would also like to know how to detect an equality
My old code (look down for the new)
Thanks,
Aralwen.
[doublepost=1535053421,1535053381][/doublepost]Hello ! I modified my code a bit, but it still does not work and I do not understand why.
So I'm summarizing what I would like my code to do :
New code:
I do not know how detect the person who has received the most votes.
I would also like to know how to detect an equality
My old code (look down for the new)
code_language.skript:
command /openvote:
description: Open the votes
trigger:
set {vote} to now
clear {votep::*}
broadcast "The votes are open for two minutes! /vote PSEUDO"
wait 2 minutes
broadcast "The most voted player is: ...."
command /vote [<player>]:
description: Vote a player
trigger:
if difference between {vote} and now is less than 2 minutes:
if {vote::%player%} is not set:
set {votep::%player%} to now
add 1 to {ListVote.%arg-player%}
send "&aYour vote has been counted"
else:
send "&cYou have already voted."
else:
send "&cThe votes are not open yet"
Thanks,
Aralwen.
[doublepost=1535053421,1535053381][/doublepost]Hello ! I modified my code a bit, but it still does not work and I do not understand why.
So I'm summarizing what I would like my code to do :
- A player starts the vote with /openvote, the players have 2 minutes to vote.
- After 2 minutes, the most voted player is announced with the number of votes he has
- In case of a tie, it sends a message of the style "The players have not managed to decide"
- If no one has voted, it says so
New code:
code_language.skript:
command /openvote:
description: Open the votes
trigger:
set {VoteTimer} to now
clear {vote::*}
clear {VoteList::*}
broadcast "&aThe votes are open for two minutes! Use &a&l/vote PSEUDO"
every 1 second:
if difference between {VoteTimer} and now is more than 2 minutes:
clear {VoteTimer}
loop {VoteList::*}:
if loop-value is higher than 0:
set {_vote} to loop-value
set {_voteplayer} to loop-index parsed as player
if {_voteplayer} is set:
broadcast "&eThe most voted player is: &e&l%{_voteplayer}% &e- Voted by &e&l%{VoteList::%{_voteplayer}%}% people"
else:
broadcast "&cNobody voted!"
command /vote [<player>]:
description: Vote a player
trigger:
if difference between {VoteTimer} and now is less than 2 minutes:
if {Vote::%player's uuid%} is not set:
set {Vote::%player's uuid%} to now
add 1 to {VoteList::%arg-player%}
send "&aYour vote has been counted"
else:
send "&cYou have already voted."
else:
send "&cThe votes are not open yet"