Percentage

  • 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.

Deku

Member
Jul 12, 2020
36
0
6
19
How do you get the percentage of who voted yes and no among all players?

Code:
variables:
    {votisi::*} = 0
    {votino::*} = 0
    
command /aprivoto:
    trigger:
        delete {votisi::*}
        delete {votino::*}
        set {voto::*} to "&e''&aTi sta piacendo il server?&e''"
        broadcast "&6&lFra 30 secondi ci sarà una votazione! %{voto::*}%"
        wait 30 seconds
        loop all players:
            make loop-player execute command "asajsgsyin2h67z62h2289g6nzm"
    
command /asajsgsyin2h67z62h2289g6nzm:
    description: Vote a player
    trigger:
        open chest with 3 rows named "&a&lVotazione: %{voto::*}%" to player
        wait 0 tick       
        format slot 11 of player with wool named "&a&lSì!" to close then run [execute player command "wp789120osia"]   
        format slot 12 of player with wool named "&c&lNo!" to close then run [execute player command "su88129nmsAM7S79A"]
        
command /wp789120osia:
    trigger:
        add 1 to {votisi::*}
        send "&aHai votato ''&2Sì&a'' alla domanda %{voto::*}%&a!"
        
command /su88129nmsAM7S79A:
    trigger:
        add 1 to {votino::*}
        send "&cHai votato ''&4No&c'' alla domanda %{voto::*}%&c!"
        
command /listavoti:
    trigger:
        if size of {votisi::*} is not 0 or 1:
            send "&e%{votisi::*}% &7persone hanno votato &2Sì" to executor
        else if size of {votisi::*} is 1:
            send "&e1 &7persona ha votato &6Sì" to executor       
        else if size of {votisi::*} is 0:
            send "&eNessuna persona ha votato &2Sì" to executor   
        if size of {votino::*} is not 0 or 1:           
            send "&e%{votino::*}% &7persone hanno votato &4No" to executor
        else if size of {votino::*} is 1:
            send "&e1 persona ha votato &4No" to executor       
        else if size of {votino::*} is 0:
            send "&eNessuna persona ha votato &4No" to executor
 
Code:
        set {totalvotes} to size of {votisi::*}+size of {votino::*}
        set {_vn} to size of {votino::*}
        set {_vy} to size of {votisi::*}
        set {_votenopercent} to "%round(({_vn}*100)/{totalvotes})%%%"
        set {_voteyespercent} to "%round(({_vy}*100)/{totalvotes})%%%"
        send "&cNo: %{_votenopercent}%"
        send "&aYes: %{_voteyespercent}%"
 
Code:
        set {totalvotes} to size of {votisi::*}+size of {votino::*}
        set {_vn} to size of {votino::*}
        set {_vy} to size of {votisi::*}
        set {_votenopercent} to "%round(({_vn}*100)/{totalvotes})%%%"
        set {_voteyespercent} to "%round(({_vy}*100)/{totalvotes})%%%"
        send "&cNo: %{_votenopercent}%"
        send "&aYes: %{_voteyespercent}%"
Thanks you to much! it works
 
Status
Not open for further replies.