On Inventory slot click

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

bobby

Active Member
Jan 28, 2017
61
0
6
26
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?
 
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?

I did it with Umbaska and TuSke:

code_language.skript:
on inventory click: 
    inventory name of current inventory of player is "NAME OF GUI YOU CREATE WITH TuSKe":
        clicked slot is 2:
            cancel event
 
@Hobbit41 he wants the inventory to be their own inventory, not a chest gui or anything of the sort.

code_language.skript:
on inventory click:
    name of clicked item is "name of your item"
    cancel event
    #do stuff?

Most of the time I just compare with the item name. It's better.
 
@Hobbit41 he wants the inventory to be their own inventory, not a chest gui or anything of the sort.

code_language.skript:
on inventory click:
    name of clicked item is "name of your item"
    cancel event
    #do stuff?

Most of the time I just compare with the item name. It's better.

so even for own inventory solution is the same
 
That won't work for me because my plugin constantly changes the item name but not the slot so yeah..
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_language.skript:
on inventory click:
    clicked slot is 2
    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_language.skript:
on inventory click:
    clicked inventory is PLAYER
    clicked slot is 2
    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.
 
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_language.skript:
on inventory click:
    clicked slot is 2
    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_language.skript:
on inventory click:
    clicked inventory is PLAYER
    clicked slot is 2
    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.
Doesn't work. I get no errors but I can still move it.
 
Doesn't work. I get no errors but I can still move it.
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"
 
I know this is late but for anyone still wondering i did this
Code:
on inventory click:
    if player doesn't have permission "moveinv":
        cancel event
So people with that permission can still like build in spawn and stuff.
 
I know this is late but for anyone still wondering i did this
Code:
on inventory click:
    if player doesn't have permission "moveinv":
        cancel event
So people with that permission can still like build in spawn and stuff.
Thats not what he was demanding.
 
@Hobbit41 he wants the inventory to be their own inventory, not a chest gui or anything of the sort.

code_language.skript:
on inventory click:
    name of clicked item is "name of your item"
    cancel event
    #do stuff?

Most of the time I just compare with the item name. It's better.

It gives me an error "item is not an item type"