Help 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 community!

    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!

IcyCappuccino

New Member
Sep 25, 2022
5
0
1
Hello, I have this skript with gui for kits, but I can't get 'on inventory click' event to work... I don't get any errors when reloading the skript at all... It just doesn't do anything when I click an item... I kept on trying and i'm getting really pissed off now...

Code:
command /kits:
    trigger:
        set {_slot} to 0
        open chest with 6 rows named "&cPick a Kit" to player
        loop 54 times:
            if {_slot} is 11:
                format slot {_slot} of player with golden sword named "&e&lKit Starter" with lore "&8(&730 seconds cooldown&8)" to be unstealable
            else:
                if {_slot} is 14:
                    format slot {_slot} of player with iron sword named "&7&lKit Iron" with lore "&8(&710 minutes cooldown&8)" to be unstealable
                else:
                    if {_slot} is 15:
                        format slot {_slot} of player with diamond sword named "&b&lKit Diamond" with lore "&8(&72 hours cooldown&8)" to be unstealable
                    else:
                        if {_slot} is 39:
                            format slot {_slot} of player with nether star named "&aDonator Kits" to be unstealable
                        else:
                            if {_slot} is 41:
                                format slot {_slot} of player with chest named "&a&lStore" to be unstealable
                            else:
                                if {_slot} is 49:
                                    format slot {_slot} of player with arrow named "&cClose" to be unstealable
                                else:
                                    if {_slot} is 12:
                                        format slot {_slot} of player with golden sword named "&e&lKit Starter+" with lore "&8(&760 seconds cooldown&8)" to be unstealable
                                    else:
                                        if {_slot} is 13:
                                            format slot {_slot} of player with golden sword named "&e&lKit Starter++" with lore "&8(&790 seconds cooldown&8)" to be unstealable
                                        else:
                                            if {_slot} is 10 or 16 or 25 or 34 or 43 or 19 or 28 or 37 or 38 or 40 or 42:
                                                format slot {_slot} of player with purple stained glass pane named "&a" to be unstealable
                                            else:
                                                if {_slot} is 20 or 21 or 22 or 23 or 24:
                                                    format slot {_slot} of player with white stained glass pane named "&a" to be unstealable
                                                else:
                                                    format slot {_slot} of player with black stained glass pane named "&a" to be unstealable
            add 1 to {_slot}
command /kit:
    trigger:
        make player execute command "kits"

on inventory click:
    set {_clickedItem} to event-item
    if {_clickedItem} is a golden sword named "&e&lKit Starter++":
        send "hi" to player
 
First of all, you should be using else if instead of making a new line every time. For example
AppleScript:
loop 54 times:
    if {_slot} is 11:
        format slot {_slot} of player with golden sword named "&e&lKit Starter" with lore "&8(&730 seconds cooldown&8)" to be unstealable
    else if {_slot} is 14:
        format slot {_slot} of player with iron sword named "&7&lKit Iron" with lore "&8(&710 minutes cooldown&8)" to be unstealable
    else if {_slot} is 15:
        format slot {_slot} of player with diamond sword named "&b&lKit Diamond" with lore "&8(&72 hours cooldown&8)" to be unstealable
    else if {_slot} is 39:
        format slot {_slot} of player with nether star named "&aDonator Kits" to be unstealable
    else if {_slot} is 41:
        format slot {_slot} of player with chest named "&a&lStore" to be unstealable

What addon are you using to make this gui? You open the inventory as if it was just normal skript but then you format it and make it unstealable which reminds me a lot of Tuske (although I guess it could be skript-gui just as easily). If you are using an addon to make the gui, the addon should also have a system to detect clicks. With skript-gui you can make a section out of the format line.

Also you don't really need to use the loop for this. All of the non-glass items can be set individually which would be the same, if not less, effort that it took to set it in the loop. And you can set multiple slots at the same time for the glass. I would recommend using format slot (integers between 20 and 24) of player with white stained glass pane. You could also write out the numbers manually format slot (20, 21, 22, 23 and 24) of player with white stained glass pane
 
I have SkRayFall, SkQuerry and SkSkellett installed, but I don't think any of these are actually 'used' in the skript, for some reason tuske doesn't work for me for quiet a while, before it was my favourite addon.

Edit: forgot to add, yeah I use skript-gui as well
First of all, you should be using else if instead of making a new line every time. For example
AppleScript:
loop 54 times:
    if {_slot} is 11:
        format slot {_slot} of player with golden sword named "&e&lKit Starter" with lore "&8(&730 seconds cooldown&8)" to be unstealable
    else if {_slot} is 14:
        format slot {_slot} of player with iron sword named "&7&lKit Iron" with lore "&8(&710 minutes cooldown&8)" to be unstealable
    else if {_slot} is 15:
        format slot {_slot} of player with diamond sword named "&b&lKit Diamond" with lore "&8(&72 hours cooldown&8)" to be unstealable
    else if {_slot} is 39:
        format slot {_slot} of player with nether star named "&aDonator Kits" to be unstealable
    else if {_slot} is 41:
        format slot {_slot} of player with chest named "&a&lStore" to be unstealable

What addon are you using to make this gui? You open the inventory as if it was just normal skript but then you format it and make it unstealable which reminds me a lot of Tuske (although I guess it could be skript-gui just as easily). If you are using an addon to make the gui, the addon should also have a system to detect clicks. With skript-gui you can make a section out of the format line.

Also you don't really need to use the loop for this. All of the non-glass items can be set individually which would be the same, if not less, effort that it took to set it in the loop. And you can set multiple slots at the same time for the glass. I would recommend using format slot (integers between 20 and 24) of player with white stained glass pane. You could also write out the numbers manually format slot (20, 21, 22, 23 and 24) of player with white stained glass pane
 
Last edited:
Yeah, Tuske has been outdated for a while (probably since like 1.16). Skript-gui is the modern fork of it so they share a lot of similarities and it should be easy enough to adapt. Since you are using skript-gui i would recommend using its run section things instead of using the inventory click event. You can always consult the skript-gui wiki for examples and syntax with the guis. If you have any more questions about this please let me know.