Crate Inventory / GUI Issues

  • 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.
+===================================================+
| Skript Version: bensku-2.3.6
| Skript Addons: Skellett, SKDragon, SKRayFall, SKQuery, TuSKe
| Server Version: 1.13.2
+===================================================+

Hi there!
Recently I've been getting back into scripting and wanted to try making a script for custom lootcrates / lootboxes. I've been having some issues with not being able to get things to work or not being able to find solutions for certain things so I figured I'd make a post asking about some of the things I'm having issues with, for me to learn and for any of those having similar issues whilst scripting something. ^^

Here's a list of the issues I'm currently facing when making the script:
The script is unable and needs to be able to determine when a certain inventory is closed and:

» Once closed, it also needs to recognize what the inventory looked like prior to being closed.
» The script needs to remember what is in the inventory on close so it can do one of two things:


• On close, if all items inside the GUI are the same as when it first opened, successfully close the GUI and give the player the crate back. (As when you right click with it to open it, it takes it away)


• On close, if item(s) inside the GUI are not the same as when it first opened, prevent it from closing or reopen the same exact GUI with the same items it had before closing.

• This would also need to work with items constantly changing within the GUI as when you click on the item IN the GUI (named something like "???" with lore "Click to roll an item!" or whatever you please) it would roll through all the possible items randomly, mainly just as a Dog and Pony Show per se.

Is there anyone who could potentially help me with these issues?

Here is the code I could get down before I hit a roadstop, apologies if it's a little messy didn't
get to the point where I started cleaning it up a bit, usually do that when it's finished ^^

code_language.skript:
command givetestcrate:
    trigger:
        give 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" to player

on right click with ender chest:
    name of player's tool is "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-":
        wait 1 tick
        play sound "block.ender_chest.open" with volume 100 and pitch 0.75 at player for player
        remove 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" from player's inventory
        open chest with 6 rows named "&lIROTHAI CAVERNS LOOTBOX" to player
        if name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
            wait 1 tick
            format slot 0 of player with ender chest named "&6&l???" with lore "&7Click to roll an item!" to be unstealable

on inventory click:
    name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
        name of item is "&6&l???":
            wait 1 tick
            format slot 0 of player with diamond named "&a&lThis works" to be unstealable
        else:
            cancel the event
 
   
on place of ender chest:
    name of player's tool is "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-":
        cancel the event

(No Errors)

Thank you for your time and any potential help!
[doublepost=1558581553,1558335000][/doublepost]bump ^^ Still need help with this :c
 
You should fix stuff on the forums, not via PM, as other people might also want to use the solution.

As here is said, if you want to help him please do it on the forums.
This can also help others who have the same problem, thanks.
 
Add me on discord: AsuDev#0714
I will help you the best I can :emoji_slight_smile:

You should fix stuff on the forums, not via PM, as other people might also want to use the solution.

As here is said, if you want to help him please do it on the forums.
This can also help others who have the same problem, thanks.

On one hand, yes, I agree that this should be resolved on the forums page as this could help other people having the same issue learn how to fix it themselves. Especially since I haven't found any other posts with any kind of solution to these issues.

On the other, I don't think it would be an issue if we talked about it on discord cause if we did and we resolved it than I would just post the solution to it on this post anyways, I wouldn't just abandon it with no answer, even if we couldn't figure it out I'd at least say something.

Whatever y'all think is best, I'm down for either/or.
Let me know if we should keep this here, or if we're allowed to continue it in private as long
as we post our solution(s) here~

Also thank you for the offer of assistance Revelation and I'd love the help. c:
[doublepost=1558704182,1558695905][/doublepost]https://gyazo.com/9245d8f25f11a7b85e0b04cb42eb8811

Here, I linked a gif of something similar to what I'm trying to achieve ^^
The flickering when opening the crate is me trying to close out of the inventory but it not letting me,
one of the things I need help figuring out. And the rolling of the items, another thing I need help figuring out.
As you can see it also remembers what the items in the inventory of the crate was even when I closed out of it and it reopened itself.

I couldn't find a perfect example of what I'm trying to create that is professionally done like the one in the gif is, but it's very similar to what I'm going for.

Have you ever seen monthly crates on CosmicPvP factions? Yeah that's essentially what's supposed to be just changed a little~
 
Last edited:
I know what you want.

I think you can set more gui's on one command or event, but this will cost you a lot of time.
If you don't know what i mean, i can make a example code if you want me to.
[doublepost=1558705971,1558705650][/doublepost]Ah, i found something about crates on spigot.
This is a skript made plugin, i didn't test it so i don't know if it works.
But you can steal/take something of this code for the thing what you want.

Link: https://www.spigotmc.org/resources/simple-crates-skript.48875/
 
  • Like
Reactions: Nightmarinya
I know what you want.

I think you can set more gui's on one command or event, but this will cost you a lot of time.
If you don't know what i mean, i can make a example code if you want me to.
[doublepost=1558705971,1558705650][/doublepost]Ah, i found something about crates on spigot.
This is a skript made plugin, i didn't test it so i don't know if it works.
But you can steal/take something of this code for the thing what you want.

Link: https://www.spigotmc.org/resources/simple-crates-skript.48875/

Hmm okay thanks! I'll check it out, read through it and let you know if I find anything of use.
Thanks again! :emoji_slight_smile:
 
  • Like
Reactions: jonawoning
Hmm okay thanks! I'll check it out, read through it and let you know if I find anything of use.
Thanks again! :emoji_slight_smile:
No problem!

But there is an problem with the skript, it has an SkQuery GUI system/thing.
So i don't know if it works with your skript.
Place a reply if something don't works or anything.

:emoji_wink:
 
  • Like
Reactions: Nightmarinya
No problem!

But there is an problem with the skript, it has an SkQuery GUI system/thing.
So i don't know if it works with your skript.
Place a reply if something don't works or anything.

:emoji_wink:

Well did try applying the script to the server and it threw 28 errors, I do have SkQuery so anything related to it should work, unless of course it's an outdated script which it could easily be.

Anyways I looked into the script a little and the only "on inventory close" event of interest I could find was this one:

code_language.skript:
on inventory close:
    if {Crates.Use.In.%player%} is true: 
        set {Crates.Use.X.%player%} to false
        wait 1 tick
        open chest with 3 rows named "&bCrates&8¦&3%{Crates.InUse.%player%}%" to player
        unformat slot 9 of player
        unformat slot 10 of player
        unformat slot 11 of player
        unformat slot 12 of player
        unformat slot 13 of player
        unformat slot 14 of player
        unformat slot 15 of player
        unformat slot 16 of player
        unformat slot 17 of player
        format slot 9 of player with {Crates.Use.%player%.Item.8} to be unstealable
        format slot 10 of player with {Crates.Use.%player%.Item.9} to be unstealable
        format slot 11 of player with {Crates.Use.%player%.Item.1} to be unstealable
        format slot 12 of player with {Crates.Use.%player%.Item.2} to be unstealable
        format slot 13 of player with {Crates.Use.%player%.Item.3} to be unstealable
        format slot 14 of player with {Crates.Use.%player%.Item.4} to be unstealable
        format slot 15 of player with {Crates.Use.%player%.Item.5} to be unstealable
        format slot 16 of player with {Crates.Use.%player%.Item.6} to be unstealable
        format slot 17 of player with {Crates.Use.%player%.Item.7} to be unstealable
        format slot 0 of player with 160:5 named "&a⬛" to be unstealable
        format slot 1 of player with 160:5 named "&a⬛" to be unstealable
        format slot 2 of player with 160:5 named "&a⬛" to be unstealable
        format slot 3 of player with 160:5 named "&a⬛" to be unstealable
        format slot 5 of player with 160:5 named "&a⬛" to be unstealable
        format slot 6 of player with 160:5 named "&a⬛" to be unstealable
        format slot 7 of player with 160:5 named "&a⬛" to be unstealable
        format slot 8 of player with 160:5 named "&a⬛" to be unstealable

        format slot 18 of player with 160:5 named "&a⬛" to be unstealable
        format slot 19 of player with 160:5 named "&a⬛" to be unstealable
        format slot 20 of player with 160:5 named "&a⬛" to be unstealable
        format slot 21 of player with 160:5 named "&a⬛" to be unstealable
        format slot 23 of player with 160:5 named "&a⬛" to be unstealable
        format slot 24 of player with 160:5 named "&a⬛" to be unstealable
        format slot 25 of player with 160:5 named "&a⬛" to be unstealable
        format slot 26 of player with 160:5 named "&a⬛" to be unstealable
        play "CLICK" to player at volume 2 
        unformat slot 4 of player
        unformat slot 22 of player
        format slot 4 of player with 50 named "&9▼" to be unstealable
        format slot 22 of player with 50 named "&9▲" to be unstealable
        wait 3 tick
        play "ORB_PICKUP" to player at volume 2 
        wait 3 tick
        play "ORB_PICKUP" to player at volume 2 
        wait 3 tick
        play "ORB_PICKUP" to player at volume 2 
        wait 3 tick
        play "NOTE_PLING" to player at volume 2                 
        set {Crates.Use.In.%player%} to false
 
        give player {Crates.Use.%player%.Item.3}

I'm not quite sure if this script was able to do the 'reopen on close' thing but if it can, this was the only thing I could find potentially related to it. I'm not the master skript user myself so some of the things written in this script I'm not entirely sure what the purpose is ^^
Such as the unformatting and reformatting.

Otherwise I didn't see much in the script I could use for this specific project unless I missed something, thank you anyway :C And thank you again for the help! It really means a lot to me c:
 
  • Like
Reactions: jonawoning
No problem!
Well did try applying the script to the server and it threw 28 errors, I do have SkQuery so anything related to it should work, unless of course it's an outdated script which it could easily be.

Anyways I looked into the script a little and the only "on inventory close" event of interest I could find was this one:

code_language.skript:
on inventory close:
    if {Crates.Use.In.%player%} is true:
        set {Crates.Use.X.%player%} to false
        wait 1 tick
        open chest with 3 rows named "&bCrates&8¦&3%{Crates.InUse.%player%}%" to player
        unformat slot 9 of player
        unformat slot 10 of player
        unformat slot 11 of player
        unformat slot 12 of player
        unformat slot 13 of player
        unformat slot 14 of player
        unformat slot 15 of player
        unformat slot 16 of player
        unformat slot 17 of player
        format slot 9 of player with {Crates.Use.%player%.Item.8} to be unstealable
        format slot 10 of player with {Crates.Use.%player%.Item.9} to be unstealable
        format slot 11 of player with {Crates.Use.%player%.Item.1} to be unstealable
        format slot 12 of player with {Crates.Use.%player%.Item.2} to be unstealable
        format slot 13 of player with {Crates.Use.%player%.Item.3} to be unstealable
        format slot 14 of player with {Crates.Use.%player%.Item.4} to be unstealable
        format slot 15 of player with {Crates.Use.%player%.Item.5} to be unstealable
        format slot 16 of player with {Crates.Use.%player%.Item.6} to be unstealable
        format slot 17 of player with {Crates.Use.%player%.Item.7} to be unstealable
        format slot 0 of player with 160:5 named "&a⬛" to be unstealable
        format slot 1 of player with 160:5 named "&a⬛" to be unstealable
        format slot 2 of player with 160:5 named "&a⬛" to be unstealable
        format slot 3 of player with 160:5 named "&a⬛" to be unstealable
        format slot 5 of player with 160:5 named "&a⬛" to be unstealable
        format slot 6 of player with 160:5 named "&a⬛" to be unstealable
        format slot 7 of player with 160:5 named "&a⬛" to be unstealable
        format slot 8 of player with 160:5 named "&a⬛" to be unstealable

        format slot 18 of player with 160:5 named "&a⬛" to be unstealable
        format slot 19 of player with 160:5 named "&a⬛" to be unstealable
        format slot 20 of player with 160:5 named "&a⬛" to be unstealable
        format slot 21 of player with 160:5 named "&a⬛" to be unstealable
        format slot 23 of player with 160:5 named "&a⬛" to be unstealable
        format slot 24 of player with 160:5 named "&a⬛" to be unstealable
        format slot 25 of player with 160:5 named "&a⬛" to be unstealable
        format slot 26 of player with 160:5 named "&a⬛" to be unstealable
        play "CLICK" to player at volume 2
        unformat slot 4 of player
        unformat slot 22 of player
        format slot 4 of player with 50 named "&9▼" to be unstealable
        format slot 22 of player with 50 named "&9▲" to be unstealable
        wait 3 tick
        play "ORB_PICKUP" to player at volume 2
        wait 3 tick
        play "ORB_PICKUP" to player at volume 2
        wait 3 tick
        play "ORB_PICKUP" to player at volume 2
        wait 3 tick
        play "NOTE_PLING" to player at volume 2                
        set {Crates.Use.In.%player%} to false
 
        give player {Crates.Use.%player%.Item.3}

I'm not quite sure if this script was able to do the 'reopen on close' thing but if it can, this was the only thing I could find potentially related to it. I'm not the master skript user myself so some of the things written in this script I'm not entirely sure what the purpose is ^^
Such as the unformatting and reformatting.

Otherwise I didn't see much in the script I could use for this specific project unless I missed something, thank you anyway :C And thank you again for the help! It really means a lot to me c:

No Problem!
 
This is the only thing I've got working at the moment, I tried messing around with the rolling of the items thing but it didn't end up too well. As in, it didn't work. xc
I cleaned up the old code I had for the menu though and made it look prettier.
Learned that I could just use the loop integer thing instead of filling each slot manually =P

code_language.skript:
on right click with ender chest:
    name of player's tool is "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-":
        wait 1 tick
        open chest with 6 rows named "&lIROTHAI CAVERNS LOOTBOX" to player
        wait 1 tick
        play sound "block.ender_chest.open" with volume 100 and pitch 0.75 at player for player
        play sound "entity.firework_rocket.launch" with volume 100 and pitch 1 at player for player
        play sound "entity.player.levelup" with volume 100 and pitch 1 at player for player
        loop integers between 0 and menu size of player's current inventory - 1:
            set slot loop-number of player's current inventory to black stained glass pane named " "
        wait 1 tick
        loop integers between 12 and 15 - 1:
            set slot loop-number of player's current inventory to ender chest named "&6&l???" with lore "&7Click to redeem a random item" and "&7from the Irothai Caverns&7 Lootbox!"
        loop integers between 21 and 24 - 1:
            set slot loop-number of player's current inventory to ender chest named "&6&l???" with lore "&7Click to redeem a random item" and "&7from the Irothai Caverns&7 Lootbox!"
        loop integers between 30 and 33 - 1:
            set slot loop-number of player's current inventory to ender chest named "&6&l???" with lore "&7Click to redeem a random item" and "&7from the Irothai Caverns&7 Lootbox!"
        set slot 49 of player's current inventory to red stained glass pane named "&4&lDIVINE REWARD" with lore "&7Click to recieve a guaranteed", "&5&lEPIC&7 tier reward or higher!", "&k" and "&6Legendary&e and &4Divine&e reward", "&echances are increased!", "&k", "&4You must open your main rewards before" and "&4you can open your &nDIVINE&4 reward!"
   
on inventory click:
    name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
        cancel the event
   
command lootbox:
    trigger:
        give 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" to player
 
Last edited:
You should fix stuff on the forums, not via PM, as other people might also want to use the solution.
I always paste the solution on the forum post after helping someone on discord. I really just don't like a million back and forths especially with larger pieces of code. Still open to help with this if you need still it.
 
I always paste the solution on the forum post after helping someone on discord. I really just don't like a million back and forths especially with larger pieces of code.
I understand that, but the process of fixing something can also help people. If people see how problems are solved, they will be better at solving their own problems in the future.
 
Makes sense I guess. But yea, I still am going to offer discord help for this kind of stuff if they want help. They can accept or they don't accept.
 
Apologies for not responding to this thread for a while, I ended up going to sleep after my last post.

I understand that, but the process of fixing something can also help people. If people see how problems are solved, they will be better at solving their own problems in the future.

I do agree with TPGames, I've had lots of moments where I looked up how to do something, and got answered based off of the process of fixing the issue, and not the actual solution that the person who made the thread wanted.

Makes sense I guess. But yea, I still am going to offer discord help for this kind of stuff if they want help. They can accept or they don't accept.

I really do appreciate the offer Revelation and I can understand not wanting to deal with back and forths on forum pages.
But, since the post is already made and is here it might as well have the solutions be posted here.

I definitely don't mind talking to you at some point though if there are any more issues I come across, if you're still up for it.
What I could do in the future if you help me is just make a thread about the issue I was having and respond to myself with the solutions that we
went through to try and fix it, and then the solution that did fix it, kind of like a, "this was the issue, here's the solutions" kind of post, if that's allowed. I'm not sure if that kind of stuff is or isn't allowed, (posting and responding to myself about the solutions I mean) so if someone experienced with the forums community, probably someone like TPGames, could let me know that would be awesome, thank you~ :emoji_slight_smile:

Also one other thing I don't know if you're up for it but if we talked Revelation I'd likely add you to a public discord group I made for my friends and steam group members, it's still relatively small, but there is a Semi-Private channel we could discuss the coding and stuff in that only staff are allowed to see, and they won't likely bother us while we're talking unless they need to. Mainly just because I'm not a huge fan of talking to people I've just met in completely private areas (no offense I hope you understand what I mean though :c) but we could for sure talk in that semi-private channel I have in the server if you're interested ^^ Let me know if that's alright with you, maybe we could work together on some stuff at some point help each other out on scripts and stuff ^^ although I'm fairly certain that you know a lot more about skript than I do and most of the stuff I know you probably already know haha cx
 
Last edited:
I'm not sure if that kind of stuff is or isn't allowed, (posting and responding to myself about the solutions I mean) so if someone experienced with the forums community, probably someone like TPGames, could let me know that would be awesome, thank you~ :emoji_slight_smile:
It is allowed to post your own solution to your thread, since any solution is better than none (most of the time). It's also allowed to solve things with someone else helping you over Discord, but it's better to post all of the fixing stuff here, since others will also be able to appreciate it. So all of it is basically allowed, but posting here is just better for other people.
 
It is allowed to post your own solution to your thread, since any solution is better than none (most of the time). It's also allowed to solve things with someone else helping you over Discord, but it's better to post all of the fixing stuff here, since others will also be able to appreciate it. So all of it is basically allowed, but posting here is just better for other people.

Right~ As I said if we did do that in the future I'd post all of the "test solutions" and fixes in the post.
Everything that's related to the code, essentially.

Also still need assistance on these problems if anyone knows how to help with them ^^
If not I'll talk to Revelation about them on discord and post anything code related or anything that sounds like it could help other people to the post. But as I said, since the post was made it might as well have the solution written here, if anyone knows it~
 
+===================================================+
| Skript Version: bensku-2.3.6
| Skript Addons: Skellett, SKDragon, SKRayFall, SKQuery, TuSKe
| Server Version: 1.13.2
+===================================================+

Hi there!
Recently I've been getting back into scripting and wanted to try making a script for custom lootcrates / lootboxes. I've been having some issues with not being able to get things to work or not being able to find solutions for certain things so I figured I'd make a post asking about some of the things I'm having issues with, for me to learn and for any of those having similar issues whilst scripting something. ^^

Here's a list of the issues I'm currently facing when making the script:
The script is unable and needs to be able to determine when a certain inventory is closed and:

» Once closed, it also needs to recognize what the inventory looked like prior to being closed.
» The script needs to remember what is in the inventory on close so it can do one of two things:


• On close, if all items inside the GUI are the same as when it first opened, successfully close the GUI and give the player the crate back. (As when you right click with it to open it, it takes it away)


• On close, if item(s) inside the GUI are not the same as when it first opened, prevent it from closing or reopen the same exact GUI with the same items it had before closing.

• This would also need to work with items constantly changing within the GUI as when you click on the item IN the GUI (named something like "???" with lore "Click to roll an item!" or whatever you please) it would roll through all the possible items randomly, mainly just as a Dog and Pony Show per se.

Is there anyone who could potentially help me with these issues?

Here is the code I could get down before I hit a roadstop, apologies if it's a little messy didn't
get to the point where I started cleaning it up a bit, usually do that when it's finished ^^

code_language.skript:
command givetestcrate:
    trigger:
        give 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" to player

on right click with ender chest:
    name of player's tool is "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-":
        wait 1 tick
        play sound "block.ender_chest.open" with volume 100 and pitch 0.75 at player for player
        remove 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" from player's inventory
        open chest with 6 rows named "&lIROTHAI CAVERNS LOOTBOX" to player
        if name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
            wait 1 tick
            format slot 0 of player with ender chest named "&6&l???" with lore "&7Click to roll an item!" to be unstealable

on inventory click:
    name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
        name of item is "&6&l???":
            wait 1 tick
            format slot 0 of player with diamond named "&a&lThis works" to be unstealable
        else:
            cancel the event
 
 
on place of ender chest:
    name of player's tool is "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-":
        cancel the event

(No Errors)

Thank you for your time and any potential help!
[doublepost=1558581553,1558335000][/doublepost]bump ^^ Still need help with this :c
You can use https://skriptlang.github.io/Skript/events.html#inventory_close, then probably event-inventory and https://skriptlang.github.io/Skript/expressions.html#ExprItemsIn with event-inventory. You can also check the name of the current inventory of the player (https://skriptlang.github.io/Skript/expressions.html#ExprOpenedInventory) to check if they still have the inventory open.
 
Okay that's one of the issues down! Thank you! :emoji_slight_smile:

Here's what I used:

code_language.skript:
on inventory close:
    name of player's current inventory is "&lIROTHAI CAVERNS LOOTBOX":
        loop all items in player's current inventory:
            slot 12, 13, 14, 21, 22, 23, 30, 31 and 32 of player's current inventory is ender chest named "&6&l???" with lore "&7Click to redeem a random item" and "&7from the Irothai Caverns&7 Lootbox!":
                give 1 ender chest named "&4&l-=+> &c&k::&7 Irothai Caverns Lootbox &c&k::&4&l <+=-" with lore "&7A mysterious box found in the depths of", "&7the Irothai Caverns, there may be more", "&7down there, but this is the first of it's", "&7kind to see the light of day...", "&k", "&f&lNORMAL REWARDS:", "&7 - x32 Diamond Blocks", "&7 - x256 Bottles of Enchanting", "&7 - x2 Beacons", "&7 - x1 Irothian Pickaxe", "&7 - x64 Golden Apples", "&k", "&5&lEPIC REWARDS:", "&7 - &5x1 Reward Loot Crate &7(Tier 1 - 3)", "&7 - &5x2 Enchanted Golden Apples", "&7 - &5x1 Shulker Box", "&7 - &5x1 Mending Enchanted Book", "&7 - &5x3 Random Custom Enchants", "&k", "&6&lLEGENDARY REWARDS:", "&7 - &ex3 Random Loot Crates &7(Tier 2 - 4)", "&7 - &ex1 Experience Booster &7(4 Hours)", "&7 - &ex1 Command Access: &7/sethome, /home", "&7 - &ex5 Random Custom Enchants", "&7 - &ex1 Dragon Egg", "&7 - &ex1 Elytra", "&k", "&4&lDIVINE REWARDS:", "&7 - &cx1 &k::&7&l Irothian Knight VKit Access &c&k::", "&7 - &cx1 &k::&7&l Irothai Caverns Key &c&k::", "&7 - &cx1 Potion of Unlimited Buffs &7(3 Uses)", "&7 - &cx2 Totems of Undying", "&7 - &cx1 Random Divine Custom Enchant" and "&7 - &cx1 Admin Item" to player
                stop

I should also be able to make it determine whether or not the items in the inventory are NOT the same and make it do stuff with the same method.
Now the only issues left are:

- Items need to roll (tried doing it myself but it didn't work :/ kind of got all glitchy actually.)
- And closed inventory needs to be reopened, I'm fairly certain trying to put a "cancel the event" on a "on inventory close" event won't work but I'll try it anyways ^^

Thanks for all the help ^-^

EDIT: Yup as I suspected "on inventory close" events can't be cancelled, worth a try at least
 
Last edited:
- Items need to roll (tried doing it myself but it didn't work :/ kind of got all glitchy actually.)
What do you meaning with `roll`?

- And closed inventory needs to be reopened, I'm fairly certain trying to put a "cancel the event" on a "on inventory close" event won't work but I'll try it anyways ^^
You can try to re-open the menu on inventory close (do wait a tick). You can re-open it with `open event-inventory to player`
 
Status
Not open for further replies.