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

IViddyy

Member
Apr 17, 2022
17
1
3
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
 
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:
options:
    # Do not change!
    question: {@question}
    answer1: {@answer1}
    answer2: {@answer2}
    answer3: {@answer3}
    answer4: {@answer4}

    # You can change this
    alertMessage: "&6A poll is happening right<tooltip:&aClick here to vote in a poll><command:/poll join> &a&lhere<reset><reset>&6!"
    alreadyVotedMessage: "&cYou have already voted!"
    voteCounterMessage: "&6votes"

    # And this
    adminPermission: "op"

command /poll <text> [<text>] [<text>] [<text>] [<text>] [<text>]:
    trigger:
        arg-1 is "start":
            set {poll.ans1} to 0
            set {poll.ans2} to 0
            set {poll.ans3} to 0
            set {poll.ans4} to 0
            clear {poll.votes::*}

            set metadata tag "pollGUI" of player to chest inventory with 3 rows named "&a&lPOLL"
            set slot 4 of metadata tag "pollGUI" of player to paper named "&f&lQuestion" with lore "&6%{@question}%"
            set slot 10 of metadata tag "pollGUI" of player to red terracotta named "&6&l%{@answer1}%"
            set slot 12 of metadata tag "pollGUI" of player to lime terracotta named "&6&l%{@answer2}%"
            set slot 14 of metadata tag "pollGUI" of player to blue terracotta named "&6&l%{@answer3}%"
            set slot 16 of metadata tag "pollGUI" of player to yellow terracotta named "&6&l%{@answer4}%"
           
            broadcast {@alertMessage}

        arg-1 is "set":
            player has permission {@adminPermission}:
                set {@answer1} to arg-2
                set {@answer2} to arg-3
                set {@answer3} to arg-4
                set {@answer4} to arg-5
                set {@question} to arg-6

                send "Answer 1 set to: %{@answer1}%"
                send "Answer 2 set to: %{@answer2}%"
                send "Answer 3 set to: %{@answer3}%"
                send "Answer 4 set to: %{@answer4}%"
                send "Question set to: %{@question}%"

        arg-1 is "result":
            player has permission {@adminPermission}:
                set metadata tag "pollResultGUI" of player to chest inventory with 3 rows named "&a&lPOLL"
                set slot 4 of metadata tag "pollResultGUI" of player to paper named "&f&lQuestion" with lore "&6%{@question}%"
                set slot 10 of metadata tag "pollResultGUI" of player to red terracotta named "&6&l%{@answer1}%" with lore "&6&l%{poll.ans1}% %{@voteCounterMessage}%"
                set slot 12 of metadata tag "pollResultGUI" of player to lime terracotta named "&6&l%{@answer2}%" with lore "&6&l%{poll.ans2}% %{@voteCounterMessage}%"
                set slot 14 of metadata tag "pollResultGUI" of player to blue terracotta named "&6&l%{@answer3}%" with lore "&6&l%{poll.ans3}% %{@voteCounterMessage}%"
                set slot 16 of metadata tag "pollResultGUI" of player to yellow terracotta named "&6&l%{@answer4}%" with lore "&6&l%{poll.ans4}% %{@voteCounterMessage}%"
                open (metadata tag "pollResultGUI" of player) to player
       
        arg-1 is "join":
            if {poll.votes::*} contains player:
                send {@alreadyVotedMessage} to player
            else:
                open (metadata tag "pollGUI" of player) to player

on inventory click:
    if event-inventory = (metadata tag "pollGUI" of player):
        cancel event
        add player to {poll.votes::*}

        if event-slot is 10:
            add 1 to {poll.ans1}
            close player's inventory
        if event-slot is 12:
            add 1 to {poll.ans2}
            close player's inventory
        if event-slot is 14:
            add 1 to {poll.ans3}
            close player's inventory
        if event-slot is 16:
            add 1 to {poll.ans4}
            close player's inventory
   
    if event-inventory = (metadata tag "pollResultGUI" of player):
        cancel event
 
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:
options:
    # Do not change!
    question: {@question}
    answer1: {@answer1}
    answer2: {@answer2}
    answer3: {@answer3}
    answer4: {@answer4}

    # You can change this
    alertMessage: "&6A poll is happening right<tooltip:&aClick here to vote in a poll><command:/poll join> &a&lhere<reset><reset>&6!"
    alreadyVotedMessage: "&cYou have already voted!"
    voteCounterMessage: "&6votes"

    # And this
    adminPermission: "op"

command /poll <text> [<text>] [<text>] [<text>] [<text>] [<text>]:
    trigger:
        arg-1 is "start":
            set {poll.ans1} to 0
            set {poll.ans2} to 0
            set {poll.ans3} to 0
            set {poll.ans4} to 0
            clear {poll.votes::*}

            set metadata tag "pollGUI" of player to chest inventory with 3 rows named "&a&lPOLL"
            set slot 4 of metadata tag "pollGUI" of player to paper named "&f&lQuestion" with lore "&6%{@question}%"
            set slot 10 of metadata tag "pollGUI" of player to red terracotta named "&6&l%{@answer1}%"
            set slot 12 of metadata tag "pollGUI" of player to lime terracotta named "&6&l%{@answer2}%"
            set slot 14 of metadata tag "pollGUI" of player to blue terracotta named "&6&l%{@answer3}%"
            set slot 16 of metadata tag "pollGUI" of player to yellow terracotta named "&6&l%{@answer4}%"
          
            broadcast {@alertMessage}

        arg-1 is "set":
            player has permission {@adminPermission}:
                set {@answer1} to arg-2
                set {@answer2} to arg-3
                set {@answer3} to arg-4
                set {@answer4} to arg-5
                set {@question} to arg-6

                send "Answer 1 set to: %{@answer1}%"
                send "Answer 2 set to: %{@answer2}%"
                send "Answer 3 set to: %{@answer3}%"
                send "Answer 4 set to: %{@answer4}%"
                send "Question set to: %{@question}%"

        arg-1 is "result":
            player has permission {@adminPermission}:
                set metadata tag "pollResultGUI" of player to chest inventory with 3 rows named "&a&lPOLL"
                set slot 4 of metadata tag "pollResultGUI" of player to paper named "&f&lQuestion" with lore "&6%{@question}%"
                set slot 10 of metadata tag "pollResultGUI" of player to red terracotta named "&6&l%{@answer1}%" with lore "&6&l%{poll.ans1}% %{@voteCounterMessage}%"
                set slot 12 of metadata tag "pollResultGUI" of player to lime terracotta named "&6&l%{@answer2}%" with lore "&6&l%{poll.ans2}% %{@voteCounterMessage}%"
                set slot 14 of metadata tag "pollResultGUI" of player to blue terracotta named "&6&l%{@answer3}%" with lore "&6&l%{poll.ans3}% %{@voteCounterMessage}%"
                set slot 16 of metadata tag "pollResultGUI" of player to yellow terracotta named "&6&l%{@answer4}%" with lore "&6&l%{poll.ans4}% %{@voteCounterMessage}%"
                open (metadata tag "pollResultGUI" of player) to player
      
        arg-1 is "join":
            if {poll.votes::*} contains player:
                send {@alreadyVotedMessage} to player
            else:
                open (metadata tag "pollGUI" of player) to player

on inventory click:
    if event-inventory = (metadata tag "pollGUI" of player):
        cancel event
        add player to {poll.votes::*}

        if event-slot is 10:
            add 1 to {poll.ans1}
            close player's inventory
        if event-slot is 12:
            add 1 to {poll.ans2}
            close player's inventory
        if event-slot is 14:
            add 1 to {poll.ans3}
            close player's inventory
        if event-slot is 16:
            add 1 to {poll.ans4}
            close player's inventory
  
    if event-inventory = (metadata tag "pollResultGUI" of player):
        cancel event
thanks it worked!
 
Status
Not open for further replies.