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 Ticket support system

Discussion in 'Skript' started by Aralwen, Aug 21, 2018.

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

    Aralwen Active Member

    Joined:
    May 26, 2017
    Messages:
    164
    Likes Received:
    14
    Hello everybody. I am trying to make a ticket support system. All the code is done, I just do not find how to define the creator of the ticket that will get his answer. I tried several things, I'm a little lost.

    > I would like that with the command /support TEXT, it generates a ticket. This ticket can be answered with /answer IDTICKET TEXT. The player who created the ticket gets the answer.

    The player must be anonymous.


    Code:

    Code (Skript):
    1. command /support [<text>]:
    2.   trigger:
    3.     if arg 1 is set:
    4.       set {ticketCreator::%player%} to player
    5.       set {ticketId::%player%} to "%random integer between 0 and 9999%"
    6.       send "&aYour request for help has been sent!"
    7.       loop all players:
    8.         if loop-player has the permission "Admin":
    9.           send "" to loop-player
    10.           send "&fA player has applied for help : &e%arg 1%" to loop-player
    11.           send "" to loop-player
    12.           make console execute command "tellraw %loop-player% {text:""&f» &6&lPROCESS THE REQUEST &f«"",clickEvent:{action:suggest_command,value:""/answer %{ticketId::%player%}% ""},hoverEvent:{action:show_text,value:""&eAnswer""}}"
    13.  
    14. command /answer [<text>] [<text>]:
    15.   trigger:
    16.     if {ticketId::%player%} is set:
    17.       set {p} to {ticketCreator::%player%}
    18.       delete {ticketCreator::%player%}
    19.       delete {ticketId::%player%}
    20.       send "&aYour reply has been sent!"
    21.       send "" to {_p}
    22.       send "&c%player% &fresponded to your request for help: &e%arg-text-2%" to {_p}
    23.       send "" to {_p}
    Thank's in advance !
    --- Double Post Merged, Aug 23, 2018, Original Post Date: Aug 21, 2018 ---
    Nobody has any idea? I still have not found :emoji_frowning:

     
  2. Best Answer:
    Post #9 by jjpwn1, Aug 23, 2018
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Honestly I dont even know where to start. But your big problem here is you are setting a ticket to a player... and then when the admin checks it... your looping if a variable containing that player (the admin) is set... therefor its not going to get the same ticket. The way its written you wouldn't only be able to answer your own tickets.
     
  4. Aralwen

    Aralwen Active Member

    Joined:
    May 26, 2017
    Messages:
    164
    Likes Received:
    14
    I confess I do not understand too much... My only problem is that I do not know how to set the ticket id on the player to be able to answer it and that the player gets his answer. I tried several things, but nothing gives a concrete result.

    Command: /support TEXT: Generates a ticket and sends it to all administrators
    Command: /answer <TICKETID> TEXT: Respond to the player's ticket, mark as resolved (so no one can answer) and send the answer to the player who created the ticket.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Ill be honest with you its super hard to explain how to do all this without writing it myself.
    You will need to find a way that when the player creates a ticket it creates an ID and that ID is sent to the admins.
    Then the admin would run the command with said ID
    You could use a variable like {ticket::your id here} with would have the players name in it, so when you sent it back, you send it to the player in the variable
     
    • Informative Informative x 1
  6. Aralwen

    Aralwen Active Member

    Joined:
    May 26, 2017
    Messages:
    164
    Likes Received:
    14
    If I understand correctly for the creation of ticket, I proceed like that?

    Code (Skript):
    1. set {_ticketId} to "%random integer between 0 and 9999%"
    2. set {ticket::%{_ticketId}%} to player
    Thank's for help :emoji_slight_smile:
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    yeah that would work
     
  8. Aralwen

    Aralwen Active Member

    Joined:
    May 26, 2017
    Messages:
    164
    Likes Received:
    14
    I'm trying to do something with that and I'll let you know, thanks :emoji_slight_smile:
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You are welcome :emoji_slight_smile: I hope it works out for ya
     
  10. jjpwn1

    jjpwn1 Member

    Joined:
    Aug 18, 2018
    Messages:
    12
    Likes Received:
    8
    The issue is that the way you structured your data does not match the parameters for your commands. You differentiated each ticket data by their player name, not by the ticket ID. Therefore, if you want to retrieve the ticket ID, you would need to reference the ticket player name first.

    A solution without changing the original code is to create a function that gets the original ticket creator using only the ID:

    Code (Skript):
    1.  
    2. function getTicketCreator(id: string) :: player:
    3.     loop {ticketId::*}:
    4.         if loop-value is {_id}: #If the requested ID matches with the ticket ID in {ticketId:**}
    5.             return {ticketCreator::%loop-index%} #loop-index is the name of the player
    6.  
    After that, readjust your /answer command to fit the new function:

    Code (Skript):
    1.  
    2. command /answer [<text>] [<text>]:
    3.     trigger:
    4.         set {_p} to getTicketCreator(arg-1) #Replace set {p} to {ticketCreator::%player%}
    5.         set {_name} to {_p}'s name #Replacement of %player%
    6.         if {ticketId::%{_name}%} is set:
    7.             set {_p} to {ticketCreator::%{_name}%}
    8.             delete {ticketCreator::%{_name}%}
    9.             delete {ticketId::%{_name}%}
    10.             send "&aYour reply has been sent!"
    11.             send "" to {_p}
    12.             send "&c%{_name}% &fresponded to your request for help: &e%arg-text-2%" to {_p}
    13.             send "" to {_p}
    14.  
    Aside from the unrelated json error from your tellraw command, there seems to be no problem with this code based off testing.

    However, there's a few things to note:
    • Your ticket ID is a string despite being meant as a number. This might be problematic in the future as anything you do with the ticket ID must accept string as a parameter, and not a number.
    • This is a "band-aid" fix. Imagine there are 9999 tickets in the system. That means the function has to go through every single ticket (all 9999 of them) or until it finds the correct one. It's really inefficient.
    • The real issue here is that the way you structured your data doesn't flow with your parameters. The parameters wants an ID, but the program can only differentiate data by the player name. Either change the parameters to the player's name (/answer PLAYERNAME text) to fit your data structure, or redesign your data structure to fit the parameters ( {ticket::id}, {ticket::id::name} ).
     
    • Agree Agree x 1
  11. Aralwen

    Aralwen Active Member

    Joined:
    May 26, 2017
    Messages:
    164
    Likes Received:
    14
    It works perfectly, a really thank you for help!
    Regarding the 9999 tickets (band-aid), I do not see how to proceed other than by set {ticketId::%player%} to "%random integer between 0 and 9999%"

    Besides, would you know how to block the fact that a ticket can have the same ID? (although the probability of this happening is low)
     
    #10 Aralwen, Aug 23, 2018
    Last edited: Aug 23, 2018
  12. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    the probability is VERY VERY low... but what i would do is set a variable to 1 like:
    create a command to set {ids::newid} to 1... after its set you can remove the command
    then do something like this
    Code (Skript):
    1. set {ticketId::%player%} to {ids::newid}
    2. add 1 to {ids::newid}
    then each time a ticket is created it adds 1 to the id thingy
     
    • Agree Agree x 1
  13. Aralwen

    Aralwen Active Member

    Joined:
    May 26, 2017
    Messages:
    164
    Likes Received:
    14
    Not stupid, I will proceed this way. Thank you !
     
  14. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You're welcome :emoji_slight_smile:
     
    • Friendly Friendly x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...