Stash skript help

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

Syph

Member
Apr 20, 2021
2
0
1
23
So I'm asking for help again.

I'm trying to make a stash system similar to hypixel's and I cant come up with how to make it. Here is my current code:
JavaScript:
command /stash:
    aliases: /pickupstash
    trigger:
        if {stash::%player's uuid%::*} is set:
            if player has enough space for {stash::%player's uuid%::*}:
                send "&aʏᴏᴜ ᴄʟᴀɪᴍᴇᴅ ʏᴏᴜʀ ѕᴛᴀѕʜ!" to player
                send "%{stash::%player's uuid%::*}%" to player #debugging code
                give player {stash::%player's uuid%::*}
                clear {stash::%player's uuid%::*}
                play sound "block.note_block.pling" at volume 1 at pitch 2 to player
            else:
                send "&cʏᴏᴜʀ ɪɴᴠᴇɴᴛᴏʀʏ ᴅᴏᴇѕɴ᾽ᴛ ʜᴀᴠᴇ ᴇɴᴏᴜɢʜ ѕᴘᴀᴄᴇ!" to player
                play sound "block.note_block.pling" at volume 1 at pitch 0 to player
        else:
            send "&cʏᴏᴜʀ ѕᴛᴀѕʜ ɪѕ ᴇᴍᴘᴛʏ!" to player
            play sound "block.note_block.pling" at volume 1 at pitch 0 to player

Now this works, but only if the whole stash fits in the inventory, which could get problematic quickly.
So in my server, I have disabled item dropping to prevent players from loosing their tools, which may make the game unplayable in the event they do. So in the event a player's inventory is full, I won't be able to add important items to their inventory (such as quest items, etc.) which is the reason I need to have a stash system.

If useful, here is a snippet of the code that actually adds the item to the stash

Code:
                        wait 0.5 second
                        send "&2" to player
                        if player has enough space for wooden pickaxe:
                            give player 1 of unbreakable wooden pickaxe with no nbt with name "&7Stone Pickaxe [1]" with lore "&8Farmer Joe's old pickaxe" and "&7"
                            send "&a&l+ &7Stone Pickaxe [1]&7" to player
                        else:
                            add 1 of unbreakable wooden pickaxe with no nbt with name "&7Stone Pickaxe [1]" with lore "&8Farmer Joe's old pickaxe" and "&7" to {stash::%player's uuid%::*}
                            send "&c!ʏᴏᴜʀ ɪɴᴠᴇɴᴛᴏʀʏ ɪѕ ꜰᴜʟʟ! ᴅᴏ  /ᴘɪᴄᴋᴜᴘѕᴛᴀѕʜ ᴛᴏ ɢᴇᴛ ʏᴏᴜʀ ɪᴛᴇᴍѕ!" to player

And it works perfectly.


In short, I need the first snippet of code to be able to give the players only what they can fit in their inventory from their stash.
 
Carefull how you use this code, here was a lot of no permission commands. :emoji_grinning:
(Same type of code can be used in another script)

Code:
command /invsave:
    trigger:
        delete {magicitems::%player's uuid%::*}
        loop all items in player's inventory:
            add loop-item to {magicitems::%player's uuid%::*}

command /invsay:
    trigger:
        loop 4 times:
            send " " to player
        loop {magicitems::%player's uuid%::*}:
            send loop-value

command /pickupstash:
    trigger:
        if {magicitems::%player's uuid%::1} is set:
            loop {magicitems::%player's uuid%::*}:
                send loop-value
                if player has enough space for loop-value:
                    broadcast loop-value
                    give loop-value to the player's inventory
                    remove loop-value from {magicitems::%player's uuid%::*}
                else:
                    send "You don't have enough space for %loop-value%"
#This stop loop if player can't take an item, but if player after that need to take 1 iron ingot, and in inventory have an incomplete stack of iron ingots, the script not loop forward.
#Or you can spam the player for every loop-item.
                    stop
        else:
            send "Your stash is empty!" to player
 
Last edited:
size of {magicitems::%player's uuid%::*}
You have left %size of {magicitems::%player's uuid%::*}% items in stash