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!


    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 Determine click type

Discussion in 'Skript' started by cheatchki, Jun 27, 2017.

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

    Supporter ++

    Jun 26, 2017
    Likes Received:
    So this is probably a sad question, however I am new to skript and I can not find the answer anywhere anyways
    so I open a GUI as follows
    Code (Skript):
    1. command /punish <player>:
    2.     trigger:
    3.         set {%player%.currentpunish} to arg 1
    4.         open chest with 6 rows named "&lPunish %arg 1%" to player
    5.         wait 1 tick
    6.         format slot 10 of player with cobweb named "&c&lTrolling" with lore "&6offenses: %{punishtroll.%arg 1%}%" to close then run "punishment %arg 1% troll %player%"
    this works great and all however it means I can't differentiate the clicks. I would like to be able to add custom commands to each different click be it middle, shiftR, shiftL, Right, or left.

    I have tried something like this
    Code (Skript):
    1. on inventory click:
    2.     if inventory name of player's current inventory is "&lPunish %{%player%.currentpunish}%":
    3.         cancel the event
    4.         if clicked type is middle mouse button:
    5.             message "middle"
    6.         else:
    7.             message "unconfigured"
    and I set the to close then run to just to close. However whenever I try to click on the item it just closes the inventory. Yet whenever I click anywhere else my little add-on code works just fine.
    I'm not exactly sure what I may be doing wrong, I have latest skript, skquery, and Umbaska installed.
  2. ShaneBee

    Supporter + Addon Developer

    Sep 7, 2017
    Likes Received:
    First of all, if you have Umbaska 2, you should remove it as it's known to be buggy. And for that, you shouldn't use the format slot as this is also known to be really buggy and annoying. Your issue is that the format slot is cancelling the inventory click event, therefore, not triggering the inventory click event in the script and not running your code.

    You can use set slot if you wanna do that. It should look something like this:

    Code (Skript):
    1. command punish <player>:
    2.     trigger:
    4.         open chest with 6 rows named "<bold>Punish %arg-1%" to player
    6.         #with the set slot, you don't have to wait a tick.
    7.         #Also, the use of player's name as prefix of your variable is discouraged and you shouldn't do that.
    8.         #It's also discouraged to use single variables where you can use a list variable, keep that in mind. A better variable would be:
    10.         set slot 10 of player's inventory to cobweb named "<light red><bold>Trolling" with lore "<brown>offenses: %{punishtroll::%arg-1's uuid%}"
    12. on inventory click:
    14.     set {_name} to subtext of display name of event-inventory from 1 to (length of "Punish" + 1)
    16.     if uncolored {_name} is "Punish":
    18.         cancel the event
    20.         if type of event-slot is coweb:
    21.             if event-click action is middle mouse button:
    23.                 send "middle"
    25.             else:
    27.                 send "unconfigured"
  3. ShaneBee

    Supporter + Addon Developer

    Sep 7, 2017
    Likes Received:
    Well, I tried out implementing most of your code into mine, however the cobweb is going into slot 10 of a default player inventory, not the chest inventory. (so cobweb is going into what should be slot 55 of the chest)
    --- Double Post Merged, Jun 27, 2017, Original Post Date: Jun 27, 2017 ---
    Cancel that, however thank you Snow-Pyon for the help, I looked around a bit more found some extra events and finally have it set up properly!
Thread Status:
Not open for further replies.

Share This Page