Inventory saving

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

Jun 23, 2023
32
0
6
30
Code:
command /chest <integer>:
    trigger:
        if arg-1 > 0 and arg-1 <= 11:
            open chest with 6 rows named "Vault %arg-1%" to player
            set {_slot} to 0
            loop all items in the player's inventory 54 times:
                add loop-item to {saved::%player%::%arg-1%::*}
                format slot {_slot} of player with {saved::%player%::%arg-1%::%{_slot}%}
                add 1 to {_slot}

on inventory close:
    loop 54 times:
        if name of event-inventory contains "Vault":
            set {_name} to name of event-inventory
            replace all "Vault" with "" in {_name}
            add loop-item to {saved::%player%::%{_name}%::*}
this was supposed to save items in the specific vaault of player
 
Here ive tested it in-game too
Code:
command /chest <integer>:
    trigger:
        if arg-1 > 0:
            if arg-1 <= 11:
                set {_gui} to a new chest inventory with 6 rows named "Vault %arg-1%"
                if {saved::%player's uuid%::%arg-1%::*} is set:
                    set {_slot} to 0
                    loop {saved::%player's uuid%::%arg-1%::*}:
                        set slot {_slot} of {_gui} to loop-value
                        set {_slot} to {_slot} + 1
                open {_gui} to player

on inventory close:
    if name of event-inventory contains "Vault":
        set {_num} to name of event-inventory
        replace all "Vault " with "" in {_num}
        delete {saved::%player's uuid%::%{_num}%::*}
        loop all items in event-inventory:
            set {_name} to name of event-inventory
            replace all "Vault " with "" in {_name}
            add loop-value to {saved::%player's uuid%::%{_name}%::*}