1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Save chest

Discussion in 'Skript' started by Vxnku, Jan 1, 2023.

Thread Status:
Not open for further replies.
  1. Vxnku

    Vxnku Member

    Joined:
    Nov 29, 2022
    Messages:
    15
    Likes Received:
    0
    Code (Text):
    1. command /backpack2:
    2.     permission: op
    3.     trigger:
    4.         player has permission "op"
    5.         open chest to player
    6.         save chest
    I want the chest to be saved when closing, and if possible, to have it for each player separately
     
  2. _BraydenKing

    _BraydenKing Member

    Joined:
    May 12, 2021
    Messages:
    13
    Likes Received:
    0
    Since skript doesn't allow for you to save specific inventories, you have to save the specific items inside of the inventory as a variable instead. Something like this should work:


    Code (Text):
    1. command /backpack2:
    2.     permission: op
    3.     trigger:
    4.         if {backpack::%uuid of player%::*} is set:
    5.             open chest with 3 rows named "&8Backpack &7- &b%player%" to player
    6.             set player's current inventory to {backpack::%uuid of player%::*}
    7.             delete {backpack::%uuid of player%::*}
    8.             stop
    9.         open chest with 3 rows named "&8Backpack &7- &b%player%" to player
    10.        
    11. on inventory close:
    12.     if name of event-inventory is "&8Backpack &7- &b%player%":
    13.         loop all items in event-inventory:
    14.             add loop-value to {backpack::%uuid of player%::*}
     
  3. Vxnku

    Vxnku Member

    Joined:
    Nov 29, 2022
    Messages:
    15
    Likes Received:
    0


    Many thanks! It works and great
    But I still don't understand how containers(arrays) work, and I want to write a command
    /open backpack2 <player>
    and how to insert open array arg-2
     
  4. Merrical

    Supporter

    Joined:
    Jul 27, 2020
    Messages:
    29
    Likes Received:
    3
    If i'm correct, arrays don't exist in skript. instead there are lists: {list::*}. You can set individual index of the list like this: set {list::5} to 5.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...