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!

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

On Inventory slot click

Discussion in 'Requests' started by bobby, Aug 15, 2017.

  1. bobby

    bobby Well-Known Member

    Joined:
    Jan 28, 2017
    Messages:
    60
    Likes Received:
    0
    Skript Version: 2.2-dev25
    Minecraft Version: 1.10.2

    Hey! I'm trying to make a skript where if a player clicks on the slot "2" in his/her's inventory it won't move. How could I do this?
     
  2. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    I did it with Umbaska and TuSke:

    Code (Skript):
    1. on inventory click:
    2.     inventory name of current inventory of player is "NAME OF GUI YOU CREATE WITH TuSKe":
    3.         clicked slot is 2:
    4.             cancel event
    5.  
     
  3. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    @Hobbit41 he wants the inventory to be their own inventory, not a chest gui or anything of the sort.

    Code (Skript):
    1. on inventory click:
    2.     name of clicked item is "name of your item"
    3.     cancel event
    4.     #do stuff?
    Most of the time I just compare with the item name. It's better.
     
  4. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    so even for own inventory solution is the same
     
  5. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    That won't work for me because my plugin constantly changes the item name but not the slot so yeah..
     
  6. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    Right now i don't remember how exactly, but:

    The problem here is the fact that you're blocking slot 2 from being interacted with. It can easily be done with:
    Code (Skript):
    1. on inventory click:
    2.     clicked slot is 2
    3.     cancel event
    The problem with this syntax is that it will also block you from interacting with any chest's second slot, too. To avoid such thing from happening you also have to add the "clicked inventory" syntax (Skellett)

    As you can see, SkStuff also has it, but it's broken. So, instead, you use skellett one. It should work like this:

    Code (Skript):
    1. on inventory click:
    2.     clicked inventory is PLAYER
    3.     clicked slot is 2
    4.     cancel event
    The problem with this code is that i don't know if PLAYER is what clicked inventory returns if you clicked your inventory. It may be CRAFTING for what i remember, or even your name, you know.

    Test it a little, it sure works this way but i'm not certain and can't look it up right now.
     
  7. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    Doesn't work. I get no errors but I can still move it.
     
  8. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,124
    Likes Received:
    164
    Then use my code above and add a debug text message "%clicked inventory%" to check what it returns, because it's most likely what i told you.
    ...two weeks ago: "i don't know if PLAYER is what clicked inventory returns"
     
  9. Fainton

    Fainton Member

    Joined:
    Mar 24, 2019
    Messages:
    8
    Likes Received:
    0
    I know this is late but for anyone still wondering i did this
    Code (Text):
    1. on inventory click:
    2.     if player doesn't have permission "moveinv":
    3.         cancel event
    So people with that permission can still like build in spawn and stuff.
     
  10. Runakai

    Runakai Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    410
    Likes Received:
    23
    Thats not what he was demanding.
     
  11. JustAChillDude

    Joined:
    Apr 5, 2019
    Messages:
    6
    Likes Received:
    0
    It gives me an error "item is not an item type"
     
  12. Runakai

    Runakai Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    410
    Likes Received:
    23
Loading...