Backpack

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

Very Cool Bee

New Member
May 21, 2020
7
1
0
24
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.
 
it works for me
Code:
function openBackpack(p: player):
    wait 1 tick
    open chest with 1 row named "Backpack" to {_p}
    loop 9 times:
        set slot (loop-number -1) of {_p}'s current inventory to {backpack.%{_p}%.%loop-number -1%}

on rightclick:
    if player's tool is chest:
        openBackpack(player)
    if player's offhand tool is chest:
        openBackpack(player)

on inventory close:
    if inventory name of current inventory of player is "Backpack":
        loop 9 times:
            set {backpack.%player%.%loop-number -1%} to slot (loop-number -1) of player's current inventory
 
it works for me
Code:
function openBackpack(p: player):
    wait 1 tick
    open chest with 1 row named "Backpack" to {_p}
    loop 9 times:
        set slot (loop-number -1) of {_p}'s current inventory to {backpack.%{_p}%.%loop-number -1%}

on rightclick:
    if player's tool is chest:
        openBackpack(player)
    if player's offhand tool is chest:
        openBackpack(player)

on inventory close:
    if inventory name of current inventory of player is "Backpack":
        loop 9 times:
            set {backpack.%player%.%loop-number -1%} to slot (loop-number -1) of player's current inventory
But it doesn't for me D: The items still don't show up :<
 
Try to make a little delay between opening the inventory and setting the slots.
 
Status
Not open for further replies.