1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Percentage

Discussion in 'Skript' started by Deku, Aug 11, 2020.

Thread Status:
Not open for further replies.
  1. Deku

    Deku Member

    Joined:
    Jul 12, 2020
    Messages:
    36
    Likes Received:
    0
    How do you get the percentage of who voted yes and no among all players?

    Code (Text):
    1. variables:
    2.     {votisi::*} = 0
    3.     {votino::*} = 0
    4.    
    5. command /aprivoto:
    6.     trigger:
    7.         delete {votisi::*}
    8.         delete {votino::*}
    9.         set {voto::*} to "&e''&aTi sta piacendo il server?&e''"
    10.         broadcast "&6&lFra 30 secondi ci sarà una votazione! %{voto::*}%"
    11.         wait 30 seconds
    12.         loop all players:
    13.             make loop-player execute command "asajsgsyin2h67z62h2289g6nzm"
    14.    
    15. command /asajsgsyin2h67z62h2289g6nzm:
    16.     description: Vote a player
    17.     trigger:
    18.         open chest with 3 rows named "&a&lVotazione: %{voto::*}%" to player
    19.         wait 0 tick      
    20.         format slot 11 of player with wool named "&a&lSì!" to close then run [execute player command "wp789120osia"]  
    21.         format slot 12 of player with wool named "&c&lNo!" to close then run [execute player command "su88129nmsAM7S79A"]
    22.        
    23. command /wp789120osia:
    24.     trigger:
    25.         add 1 to {votisi::*}
    26.         send "&aHai votato ''&2Sì&a'' alla domanda %{voto::*}%&a!"
    27.        
    28. command /su88129nmsAM7S79A:
    29.     trigger:
    30.         add 1 to {votino::*}
    31.         send "&cHai votato ''&4No&c'' alla domanda %{voto::*}%&c!"
    32.        
    33. command /listavoti:
    34.     trigger:
    35.         if size of {votisi::*} is not 0 or 1:
    36.             send "&e%{votisi::*}% &7persone hanno votato &2Sì" to executor
    37.         else if size of {votisi::*} is 1:
    38.             send "&e1 &7persona ha votato &6Sì" to executor      
    39.         else if size of {votisi::*} is 0:
    40.             send "&eNessuna persona ha votato &2Sì" to executor  
    41.         if size of {votino::*} is not 0 or 1:          
    42.             send "&e%{votino::*}% &7persone hanno votato &4No" to executor
    43.         else if size of {votino::*} is 1:
    44.             send "&e1 persona ha votato &4No" to executor      
    45.         else if size of {votino::*} is 0:
    46.             send "&eNessuna persona ha votato &4No" to executor        
     
  2. kamilleon

    kamilleon Member

    Joined:
    Nov 18, 2017
    Messages:
    48
    Likes Received:
    0
    Code (Text):
    1.  
    2.         set {totalvotes} to size of {votisi::*}+size of {votino::*}
    3.         set {_vn} to size of {votino::*}
    4.         set {_vy} to size of {votisi::*}
    5.         set {_votenopercent} to "%round(({_vn}*100)/{totalvotes})%%%"
    6.         set {_voteyespercent} to "%round(({_vy}*100)/{totalvotes})%%%"
    7.         send "&cNo: %{_votenopercent}%"
    8.         send "&aYes: %{_voteyespercent}%"
     
    • Winner Winner x 1
  3. Deku

    Deku Member

    Joined:
    Jul 12, 2020
    Messages:
    36
    Likes Received:
    0
    Thanks you to much! it works
     
Thread Status:
Not open for further replies.

Share This Page

Loading...