Solved Voting system

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Try setting a local variable to the player variable as a string, parsing it as a player and than use the damage effect on that
It still doesn't work :/

code_language.skript:
command /debug:
    trigger:
        set {ActualVote} to player
        set {ActualVote}'s max health to 10
        set {_health} to {ActualVote}'s health / 2
        set {_player} to {ActualVote}
        damage {_player} by {_health} hearts
        send "&aDebug: %{ActualVote}% - %{_health}%"

I also tried set {_player} to {ActualVote} parsed as a offline player
 
code_language.skript:
command /openvote:
    description: Open the votes
    trigger:
        
        {Voting} = false
        
        set {Voting} to true
        delete {Vote::*}
        delete {VoteList::*}
        broadcast "&aThe votes are open for two minutes! Use &a&l/vote PSEUDO"
        
        wait 2 minutes
        
        if {VoteList::*} is not set:
            broadcast "&cNobody voted!"
        else:
            loop {VoteList::*}:
                
                if {_player} is not set:
                    set {_player} to loop-index
                else if {VoteList::%loop-index%} > {VoteList::%{_player}%}:
                    set {_player} to loop-index
                    
            add {_player} to {_players::*}
                    
            loop {VoteList::*}:
                {VoteList::%loop-index%} = {VoteList::%{_player}%}
                add loop-index to {_players::*}
                
        if (size of {_players::*}) > 1:
            # tie between 2 or more players
        else:
            # only 1 top player
                        
        set {Voting} to false
 
 
command /vote [<player>]:
    description: Vote a player
    trigger:
        if {Voting} = true:
            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"
 
code_language.skript:
command /openvote:
    description: Open the votes
    trigger:
      
        {Voting} = false
      
        set {Voting} to true
        delete {Vote::*}
        delete {VoteList::*}
        broadcast "&aThe votes are open for two minutes! Use &a&l/vote PSEUDO"
      
        wait 2 minutes
      
        if {VoteList::*} is not set:
            broadcast "&cNobody voted!"
        else:
            loop {VoteList::*}:
              
                if {_player} is not set:
                    set {_player} to loop-index
                else if {VoteList::%loop-index%} > {VoteList::%{_player}%}:
                    set {_player} to loop-index
                  
            add {_player} to {_players::*}
                  
            loop {VoteList::*}:
                {VoteList::%loop-index%} = {VoteList::%{_player}%}
                add loop-index to {_players::*}
              
        if (size of {_players::*}) > 1:
            # tie between 2 or more players
        else:
            # only 1 top player
                      
        set {Voting} to false
 
 
command /vote [<player>]:
    description: Vote a player
    trigger:
        if {Voting} = true:
            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"

Hello, thanks for your help, but TPGamesNL proposal works, the only last problem I have now is that I can not put damage to the most voted player by a variable :/ ( #17 / #21 )
 
It still doesn't work :/

code_language.skript:
command /debug:
    trigger:
        set {ActualVote} to player
        set {ActualVote}'s max health to 10
        set {_health} to {ActualVote}'s health / 2
        set {_player} to {ActualVote}
        damage {_player} by {_health} hearts
        send "&aDebug: %{ActualVote}% - %{_health}%"

I also tried set {_player} to {ActualVote} parsed as a offline player
Try
code_language.skript:
set {_player} to "%{ActualVote}%" parsed as a player
 
Status
Not open for further replies.