Solved on inventory click problem

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

Stefqnutz

Active Member
Sep 23, 2019
67
1
8
19
been trying to fix this for the past couple days, its annoying and i have no idea what to do in order to fix it
basically, im trying to make a custom crafting system (kinda like in hypixel skyblock). I have a button that the player can press when the required recipe is met (basically when he put all the ingredients in for the item that he's trying to craft) upon pressing that button it should craft the item instantly, however sometimes you have to spam the button so it actually crafts the item. I have no clue what could cause this.
Code:
Code:
options:
    farmingboots: leather boots named "&aFarming Boots" with lore "&7Health: &a+15 ||&7Speed &a+2 || ||&a&lUNCOMMON BOOTS || ||&7Current Enchants:" with hidden enchantments
    enchantedwheat: wheat named "&aEnchanted Wheat" with lore "&a&lUNCOMMON ITEM" with hidden enchantments

#custom crafting
function openCrafting(p: player):
    open virtual chest inventory with size 5 named "Crafting" to {_p}
    set slot 0 of {_p}'s current inventory to white stained glass pane named " "
    set slot 1 of {_p}'s current inventory to white stained glass pane named " "
    set slot 2 of {_p}'s current inventory to white stained glass pane named " "
    set slot 3 of {_p}'s current inventory to white stained glass pane named " "
    set slot 4 of {_p}'s current inventory to white stained glass pane named " "
    set slot 5 of {_p}'s current inventory to white stained glass pane named " "
    set slot 6 of {_p}'s current inventory to white stained glass pane named " "
    set slot 7 of {_p}'s current inventory to white stained glass pane named " "
    set slot 8 of {_p}'s current inventory to white stained glass pane named " "
    set slot 9 of {_p}'s current inventory to white stained glass pane named " "
    set slot 10 of {_p}'s current inventory to white stained glass pane named " "
    set slot 11 of {_p}'s current inventory to white stained glass pane named " "
    set slot 15 of {_p}'s current inventory to white stained glass pane named " "
    set slot 16 of {_p}'s current inventory to white stained glass pane named " "
    set slot 17 of {_p}'s current inventory to white stained glass pane named " "
    set slot 18 of {_p}'s current inventory to white stained glass pane named " "
    set slot 19 of {_p}'s current inventory to white stained glass pane named " "
    set slot 20 of {_p}'s current inventory to white stained glass pane named " "
    set slot 24 of {_p}'s current inventory to white stained glass pane named " "
    set slot 25 of {_p}'s current inventory to lime stained glass pane named "&aCraft"
    set slot 26 of {_p}'s current inventory to white stained glass pane named " "
    set slot 27 of {_p}'s current inventory to white stained glass pane named " "
    set slot 28 of {_p}'s current inventory to white stained glass pane named " "
    set slot 29 of {_p}'s current inventory to white stained glass pane named " "
    set slot 33 of {_p}'s current inventory to white stained glass pane named " "
    set slot 34 of {_p}'s current inventory to white stained glass pane named " "
    set slot 35 of {_p}'s current inventory to white stained glass pane named " "
    set slot 36 of {_p}'s current inventory to white stained glass pane named " "
    set slot 37 of {_p}'s current inventory to white stained glass pane named " "
    set slot 38 of {_p}'s current inventory to white stained glass pane named " "
    set slot 39 of {_p}'s current inventory to white stained glass pane named " "
    set slot 40 of {_p}'s current inventory to white stained glass pane named " "
    set slot 41 of {_p}'s current inventory to white stained glass pane named " "
    set slot 42 of {_p}'s current inventory to white stained glass pane named " "
    set slot 43 of {_p}'s current inventory to white stained glass pane named " "
    set slot 44 of {_p}'s current inventory to white stained glass pane named " "



command crafting:
    trigger:
        openCrafting(player)


function clearCraftingGrid(p: player):
    #first row
    set slot 12 of {_p}'s current inventory to air
    set slot 13 of {_p}'s current inventory to air
    set slot 14 of {_p}'s current inventory to air
    #second row
    set slot 21 of {_p}'s current inventory to air
    set slot 22 of {_p}'s current inventory to air
    set slot 23 of {_p}'s current inventory to air
    #third row
    set slot 30 of {_p}'s current inventory to air
    set slot 31 of {_p}'s current inventory to air
    set slot 32 of {_p}'s current inventory to air

on inventory click:
    if inventory name of player's current inventory is "Crafting":
        if name of clicked item is " ":
            cancel event
        if name of clicked item is "&aCraft":
            cancel event
            if slot 21 of current inventory of player is 64 {@enchantedwheat}:       
                if slot 23 of player's current inventory is 64 {@enchantedwheat}:
                    if slot 30 of player's current inventory is 64 {@enchantedwheat}:
                        if slot 32 of player's current inventory is 64 {@enchantedwheat}:
                            if slot 31 of player's current inventory is air:       
                                wait 1 tick     
                                clearCraftingGrid(player)           
                                wait 1 tick
                                set slot 22 of player's current inventory to {@farmingboots}
[doublepost=1661370579,1661351900][/doublepost]bump
[doublepost=1661431735][/doublepost]bump
[doublepost=1661520739][/doublepost]bump
 
I would try using metadata for gui's, as my experience with metadata is that it's fairly simple and from my experience, it doesn't lag / break / doesn't respond, however you may need to use inventory slots instead of item names.
 
PLEASE (if you know some good ones) link me some good tutorials as I really want to finish this!
edit: thing is, im already checking for the item itself and not name / other things, i have come to the conclusion that the on inventory click event might not be "fast" enough to handle all that, however even while putting the checks in a loop it seems to give the same result
[doublepost=1661788804,1661715830][/doublepost]FIXED! The issue was because of my custom items, I have now implemented a new system which doesnt use the custom items entirely.
 
Status
Not open for further replies.