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.

Backpack

Discussion in 'Skript' started by Very Cool Bee, Jun 14, 2020.

Thread Status:
Not open for further replies.
  1. Very Cool Bee

    Very Cool Bee New Member

    Joined:
    May 21, 2020
    Messages:
    7
    Likes Received:
    1
    Hellooo!
    I recently made this skript for a backpack:

    function openBackpack(p: player):
    open chest with 1 row named "Backpack" to {_p}
    set {_s} to 0
    loop 9 times:
    set slot {_s} of {_p}'s current inventory to {backpack::%{_p}%::%{_s}%}
    add 1 to {_s}

    on inventory close:
    if name of player's current inventory is "Backpack":
    set {_s} to 0
    loop 9 times:
    set {backpack::%{_p}%::%{_s}%} to slot {_s} of player's current inventory
    add 1 to {_s}

    on right click:
    if player's tool is chest:
    openBackpack(player)
    stop
    if player's offhand tool is chest:
    openBackpack(player)
    stop

    But the problem is it doesn't save the items (or doesn't load them). The inventory opens I put something in it, I close it, open it again and the item isn't there.
     
  2. Dave

    Dave Active Member

    Joined:
    Jul 20, 2018
    Messages:
    228
    Likes Received:
    9
    it works for me
    Code (Text):
    1. function openBackpack(p: player):
    2.     wait 1 tick
    3.     open chest with 1 row named "Backpack" to {_p}
    4.     loop 9 times:
    5.         set slot (loop-number -1) of {_p}'s current inventory to {backpack.%{_p}%.%loop-number -1%}
    6.  
    7. on rightclick:
    8.     if player's tool is chest:
    9.         openBackpack(player)
    10.     if player's offhand tool is chest:
    11.         openBackpack(player)
    12.  
    13. on inventory close:
    14.     if inventory name of current inventory of player is "Backpack":
    15.         loop 9 times:
    16.             set {backpack.%player%.%loop-number -1%} to slot (loop-number -1) of player's current inventory
     
    • Agree Agree x 1
  3. Very Cool Bee

    Very Cool Bee New Member

    Joined:
    May 21, 2020
    Messages:
    7
    Likes Received:
    1
    But it doesn't for me D: The items still don't show up :<
     
  4. PC1up

    PC1up Member

    Joined:
    Jun 14, 2020
    Messages:
    15
    Likes Received:
    1
    Try to make a little delay between opening the inventory and setting the slots.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...