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.

Solved Polls Skript With GUI

Discussion in 'Skript' started by IViddyy, Jun 27, 2022.

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

    IViddyy Member

    Joined:
    Apr 17, 2022
    Messages:
    14
    Likes Received:
    1
    Hi im trying to make a poll skript with a GUI but i have no idea how to do that so i need some help.Thanks!

    Quick Edit: I need it so i can also edit the answers
     
  2. Best Answer:
    Post #2 by Sabified, Jun 28, 2022
  3. Sabified

    Sabified Member

    Joined:
    Jun 5, 2022
    Messages:
    30
    Likes Received:
    2
    Commands:
    /poll start - Start a poll
    /poll set <Answer1> <Answer2> <Answer3> <Answer4> <Question>
    /poll result - Show the results
    /poll join - Join the poll

    Options:
    alertMessage - What the broadcasted message is when you start the poll
    alreadyVotedMessage - What message is sent if you try to enter the poll multiple times
    voteCounterMessage - How the votes are displayed. eg. " votes!" " people has voted for this!" will be displayed like this "5 votes!" "3 people has voted for this!" etc.
    adminPermission - Permission for starting, setting answers and questions, and getting the result for the previous poll

    Code (Text):
    1. options:
    2.     # Do not change!
    3.     question: {@question}
    4.     answer1: {@answer1}
    5.     answer2: {@answer2}
    6.     answer3: {@answer3}
    7.     answer4: {@answer4}
    8.  
    9.     # You can change this
    10.     alertMessage: "&6A poll is happening right<tooltip:&aClick here to vote in a poll><command:/poll join> &a&lhere<reset><reset>&6!"
    11.     alreadyVotedMessage: "&cYou have already voted!"
    12.     voteCounterMessage: "&6votes"
    13.  
    14.     # And this
    15.     adminPermission: "op"
    16.  
    17. command /poll <text> [<text>] [<text>] [<text>] [<text>] [<text>]:
    18.     trigger:
    19.         arg-1 is "start":
    20.             set {poll.ans1} to 0
    21.             set {poll.ans2} to 0
    22.             set {poll.ans3} to 0
    23.             set {poll.ans4} to 0
    24.             clear {poll.votes::*}
    25.  
    26.             set metadata tag "pollGUI" of player to chest inventory with 3 rows named "&a&lPOLL"
    27.             set slot 4 of metadata tag "pollGUI" of player to paper named "&f&lQuestion" with lore "&6%{@question}%"
    28.             set slot 10 of metadata tag "pollGUI" of player to red terracotta named "&6&l%{@answer1}%"
    29.             set slot 12 of metadata tag "pollGUI" of player to lime terracotta named "&6&l%{@answer2}%"
    30.             set slot 14 of metadata tag "pollGUI" of player to blue terracotta named "&6&l%{@answer3}%"
    31.             set slot 16 of metadata tag "pollGUI" of player to yellow terracotta named "&6&l%{@answer4}%"
    32.            
    33.             broadcast {@alertMessage}
    34.  
    35.         arg-1 is "set":
    36.             player has permission {@adminPermission}:
    37.                 set {@answer1} to arg-2
    38.                 set {@answer2} to arg-3
    39.                 set {@answer3} to arg-4
    40.                 set {@answer4} to arg-5
    41.                 set {@question} to arg-6
    42.  
    43.                 send "Answer 1 set to: %{@answer1}%"
    44.                 send "Answer 2 set to: %{@answer2}%"
    45.                 send "Answer 3 set to: %{@answer3}%"
    46.                 send "Answer 4 set to: %{@answer4}%"
    47.                 send "Question set to: %{@question}%"
    48.  
    49.         arg-1 is "result":
    50.             player has permission {@adminPermission}:
    51.                 set metadata tag "pollResultGUI" of player to chest inventory with 3 rows named "&a&lPOLL"
    52.                 set slot 4 of metadata tag "pollResultGUI" of player to paper named "&f&lQuestion" with lore "&6%{@question}%"
    53.                 set slot 10 of metadata tag "pollResultGUI" of player to red terracotta named "&6&l%{@answer1}%" with lore "&6&l%{poll.ans1}% %{@voteCounterMessage}%"
    54.                 set slot 12 of metadata tag "pollResultGUI" of player to lime terracotta named "&6&l%{@answer2}%" with lore "&6&l%{poll.ans2}% %{@voteCounterMessage}%"
    55.                 set slot 14 of metadata tag "pollResultGUI" of player to blue terracotta named "&6&l%{@answer3}%" with lore "&6&l%{poll.ans3}% %{@voteCounterMessage}%"
    56.                 set slot 16 of metadata tag "pollResultGUI" of player to yellow terracotta named "&6&l%{@answer4}%" with lore "&6&l%{poll.ans4}% %{@voteCounterMessage}%"
    57.                 open (metadata tag "pollResultGUI" of player) to player
    58.        
    59.         arg-1 is "join":
    60.             if {poll.votes::*} contains player:
    61.                 send {@alreadyVotedMessage} to player
    62.             else:
    63.                 open (metadata tag "pollGUI" of player) to player
    64.  
    65. on inventory click:
    66.     if event-inventory = (metadata tag "pollGUI" of player):
    67.         cancel event
    68.         add player to {poll.votes::*}
    69.  
    70.         if event-slot is 10:
    71.             add 1 to {poll.ans1}
    72.             close player's inventory
    73.         if event-slot is 12:
    74.             add 1 to {poll.ans2}
    75.             close player's inventory
    76.         if event-slot is 14:
    77.             add 1 to {poll.ans3}
    78.             close player's inventory
    79.         if event-slot is 16:
    80.             add 1 to {poll.ans4}
    81.             close player's inventory
    82.    
    83.     if event-inventory = (metadata tag "pollResultGUI" of player):
    84.         cancel event
    85.  
    86.  
     
  4. IViddyy

    IViddyy Member

    Joined:
    Apr 17, 2022
    Messages:
    14
    Likes Received:
    1
    thanks it worked!
     
  5. Sabified

    Sabified Member

    Joined:
    Jun 5, 2022
    Messages:
    30
    Likes Received:
    2
    You're welcome!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...