Inventory

Discussion in 'Skript' started by Stefan347401, Feb 16, 2019.

  1. Hi, i would like to make the player unable to click the first, 9th, 8th and 7th slot in their hotbar.
    This is my current code:
    Code (Text):
    on inventory click:
        if clicked slot is 0:
            if {bg::player::%uuid of player%::state} is "IN-GAME":
                cancel event
        if clicked slot is 8:
            if {bg::player::%uuid of player%::state} is "IN-GAME":
                cancel event
        if clicked slot is 7:
            if {bg::player::%uuid of player%::state} is "IN-GAME":
                cancel event
        if clicked slot is 6:
            if {bg::player::%uuid of player%::state} is "IN-GAME":
                cancel event
    The problem is that, if the player is in a chest, the player can't click the first, 9th, 8th and 7th slot in their hotbar, which is good, but they also can't click the specified slots in the chest. How can i fix this?
     
  2. Check clicked inventory is player's inventory. You should also use or (clicked slot is 1, 7, 8 or 9) and check for the in game variable right after the event (less code)
     
  3. Use the on inventory click click event like this:

    Code (Text):
    command /test:
        trigger:
            open chest with 1 row named "Test" to player
            set slot 4 of player's current inventory to paper named "Test"

    on inventory click:
        if player's current inventory contains paper named "Test":
            cancel event
            #code

    #Now it'll only refuse people to take stuff in or out the inventory when the inventory has a specific item or title.