Solved Problem with inventory 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
I'll post the ENTIRE code to make you see better.
code_language.skript:
on inventory click:
    if inventory name of player's current inventory is "&a&lShop":
        if clicked inventory is not player's inventory:
            if clicked slot is 19:
                cancel event
                wait a tick
                open chest with 3 rows named "&bEnchantements" to player
                set slot 10 of player's current inventory to shiny paper named "&bAffilatezza"
                set slot 26 of player's current inventory to sign named "&e <- &7Ritorna al menù precedente"
    if name of player's current inventory contains "&bEnchantements":
        if clicked inventory is not player's inventory:
            if clicked slot is 10:
                cancel event
                wait a tick
                open chest with 3 rows named "&9Affilatezza" to player
                set slot 10 of player's current inventory to 1 of shiny paper named "&eAffilatezza 1"
                set slot 11 of player's current inventory to 2 of shiny paper named "&eAffilatezza 2"
                set slot 12 of player's current inventory to 3 of shiny paper named "&eAffilatezza 3"
                set slot 13 of player's current inventory to 4 of shiny paper named "&eAffilatezza 4"
                set slot 14 of player's current inventory to 5 of shiny paper named "&eAffilatezza 5"
                set slot 26 of player's current inventory to sign named "&e<- &7Ritorna al menù precedente"
            if clicked slot is 26:
                cancel event
                wait a tick
                open chest with 5 rows named "&a&lShop" to player
                set slot 19 of player's current inventory to book named "&bEnchantements"
                set slot 21 of player's current inventory to ("SimoneDN20" parsed as offline player)'s skull named "&6&lKits"
    if inventory name of player's current inventory is "&9Affilatezza":
        if clicked inventory is not player's inventory:
            if clicked slot is 10:
                cancel event
                if {superlydiamonds.%player%} >= 70:
                    give player an enchanted book of sharpness 1 with custom nbt "{StoredEnchantments:[{id:16,lvl:1}]}"
                    close player's inventory
                    remove 70 from {superlydiamonds.%player%}
                    send "Shop>&7 Hai speso&e 70&7 SuperlyDiamonds per ottenere un&a Libro di incantagione per affilatezza 1&7!" to player
                else:
                    send "&9Shop> &7Non hai abbastanza Superly Diamonds per ottenere quell'oggetto! (&a%{superlydiamonds.%player%}%/&c70&7)" to player
            if clicked slot is 11:
                cancel event
                if {superlydiamonds.%player%} >= 70:
                    give player an enchanted book of sharpness 2 with custom nbt "{StoredEnchantments:[{id:16,lvl:2}]}"
                    close player's inventory
                    remove 70 from {superlydiamonds.%player%}
                    send "Shop>&7 Hai speso&e 70&7 SuperlyDiamonds per ottenere un&a Libro di incantagione per affilatezza 2&7!" to player
                else:
                    send "&9Shop> &7Non hai abbastanza Superly Diamonds per ottenere quell'oggetto! (&a%{superlydiamonds.%player%}%/&c70&7)" to player
            if clicked slot is 12:
                cancel event
                if {superlydiamonds.%player%} >= 70:
                    give player an enchanted book of sharpness 3 with custom nbt "{StoredEnchantments:[{id:16,lvl:3}]}"
                    close player's inventory
                    remove 70 from {superlydiamonds.%player%}
                    send "Shop>&7 Hai speso&e 70&7 SuperlyDiamonds per ottenere un&a Libro di incantagione per affilatezza 3&7!" to player
                else:
                    send "&9Shop> &7Non hai abbastanza Superly Diamonds per ottenere quell'oggetto! (&a%{superlydiamonds.%player%}%/&c70&7)" to player
            if clicked slot is 13:
                cancel event
                if {superlydiamonds.%player%} >= 70:
                    give player an enchanted book of sharpness 4 with custom nbt "{StoredEnchantments:[{id:16,lvl:4}]}"
                    close player's inventory
                    remove 70 from {superlydiamonds.%player%}
                    send "Shop>&7 Hai speso&e 70&7 SuperlyDiamonds per ottenere un&a Libro di incantagione per affilatezza 4&7!" to player
                else:
                    send "&9Shop> &7Non hai abbastanza Superly Diamonds per ottenere quell'oggetto! (&a%{superlydiamonds.%player%}%/&c70&7)" to player
            if clicked slot is 14:
                cancel event
                if {superlydiamonds.%player%} >= 70:
                    give player an enchanted book of sharpness 5 with custom nbt "{StoredEnchantments:[{id:16,lvl:5}]}"
                    close player's inventory
                    remove 70 from {superlydiamonds.%player%}
                    send "Shop>&7 Hai speso&e 70&7 SuperlyDiamonds per ottenere un&a Libro di incantagione per affilatezza 5&7!" to player
                else:
                    send "&9Shop> &7Non hai abbastanza Superly Diamonds per ottenere quell'oggetto! (&a%{superlydiamonds.%player%}%/&c70&7)" to player
            if clicked slot is 26:
                cancel event
                wait a tick
                open chest with 3 rows named "&bEnchantements" to player
                set slot 10 of player's current inventory to shiny paper named "&9Affilatezza"
                set slot 26 of player's current inventory to sign named "&e <- &7Ritorna al menù precedente"
 
This is what White is talking about, make sure your slot numbering is correct,
gK9plGo.png
 
You have a lot of repeating lines of code, this might work, give it a try.
code_language.skript:
on inventory click:
    if name of player's current inventory contains "&bEnchantements":
            if clicked inventory is not player's inventory:
                if clicked slot is 11:
                    wait a tick
                    open chest with 3 rows named "&9Affilatezza" to player
                    format slot 10 of player to 1 of shiny paper named "&eAffilatezza 1" to be unstealable
                    format slot 11 of player to 2 of shiny paper named "&eAffilatezza 2" to be unstealable
                    format slot 12 of player to 3 of shiny paper named "&eAffilatezza 3" to be unstealable
                    format slot 13 of player to 4 of shiny paper named "&eAffilatezza 4" to be unstealable
                    format slot 14 of player to 5 of shiny paper named "&eAffilatezza 5" to be unstealable
                    format slot 26 of player to sign named "&e<- &7Ritorna al menù precedente" to be unstealable
 
If that doesn't work you need to do some basic debugging, you can test to see what you're doing wrong with this code:
code_language.skript:
on inventory click:
    #CHECK:: Slot Type:: https://docs.skunity.com/syntax/search/inventory%20clicked%20slot%20type
    broadcast "Slot type: &b%clicked slot type%"
    #CHECK:: Slot Number:: https://docs.skunity.com/syntax/search/clicked%20slot
    broadcast "Slot: &6%clicked slot%"
    #CHECK:: All-In-One, Requires skMorkaz:: https://docs.skunity.com/syntax/search/on%20mor
    #broadcast "%event-item%, %cursor-item%, %event-inventory%, %player%, %event-number%"
If you still can't figure it out, then oh well.
 
If that doesn't work you need to do some basic debugging, you can test to see what you're doing wrong with this code:
code_language.skript:
on inventory click:
    #CHECK:: Slot Type:: https://docs.skunity.com/syntax/search/inventory%20clicked%20slot%20type
    broadcast "Slot type: &b%clicked slot type%"
    #CHECK:: Slot Number:: https://docs.skunity.com/syntax/search/clicked%20slot
    broadcast "Slot: &6%clicked slot%"
    #CHECK:: All-In-One, Requires skMorkaz:: https://docs.skunity.com/syntax/search/on%20mor
    #broadcast "%event-item%, %cursor-item%, %event-inventory%, %player%, %event-number%"
If you still can't figure it out, then oh well.
Or use TuSKe which essentially solves all the problems for GUI stuff.
 
What was the issue?
I suggest you post your solution for any future thread viewers in need/with the same issue aas you.
 
I don't even know the issue, i'll just use TuSke GUI Manager and i'll try to solve the question.. Maybe it is better than format slot..
 
Status
Not open for further replies.