Need help looping items in a chest and removing them

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

Hassan7000

Member
Mar 12, 2018
23
3
0
24
hey im creating a chestsell skript that allow players to easy sell there loot and i dont know how to loop the items in the chest and removing them and how many items there are in the chest and what items

code_language.skript:
on sign change:
    if line 1 is "[ChestSell]":
        set line 1 to "&7[&6&lChestSell&7]"
        set line 2 to "&6&l%player%"
        message "&aYou have created a ChestSell"
        
on rightclick on a chest or trapped chest:
    if type of loop-block is wall sign:
      if line 1 of loop-block is "&7[&6&lChestSell&7]":
        set {chestloc.%player%} to location of loop-block
        remove 1 sign from {_tmpchest}
I have tried something here but its not working
[doublepost=1520960942,1520883759][/doublepost]bump
 
Signs on their own don't hold an inventory. You'd have to like add the item clicked on it to a list variable and then loop that list or open up a gui that they could use. If you use an actual chest that can store an inventory, you could do something like this
code_language.skript:
loop all items in inventory of clicked block:
    remove loop-item from event-block
    #or perhaps
    remove loop-item from inventory of clicked block
 
Signs on their own don't hold an inventory. You'd have to like add the item clicked on it to a list variable and then loop that list or open up a gui that they could use. If you use an actual chest that can store an inventory, you could do something like this
code_language.skript:
loop all items in inventory of clicked block:
    remove loop-item from event-block
    #or perhaps
    remove loop-item from inventory of clicked block
Didnt work can you help me fix this

My code now
code_language.skript:
on rightclick on a chest or trapped chest:
    if type of event-block is wall sign:
        if line 1 of event-block is "&7[&6&lChestSell&7]":
        set {chestloc.%player%} to location of event-block
        loop all items in inventory of clicked block:
            remove loop-item from inventory of clicked block
 
Didnt work can you help me fix this

My code now
code_language.skript:
on rightclick on a chest or trapped chest:
    if type of event-block is wall sign:
        if line 1 of event-block is "&7[&6&lChestSell&7]":
        set {chestloc.%player%} to location of event-block
        loop all items in inventory of clicked block:
            remove loop-item from inventory of clicked block
Signs do not have an inventory. You'll need to add the items to a list variable and then loop that
 
If your mean is The player places item in the chest and clicks on the sign on the chest to sell all items in it, you can try this:

code_language.skript:
on rightclick on wall sign:
    if block at block under event-block is a chest or trapped chest:
        if line 1 of event-block is "&7[&6&lChestSell&7]":
            set {chestloc.%player%} to location of event-block
            loop all items in inventory of block at block under clicked block:
                remove loop-item from inventory of block at block under clicked block
 
If your mean is The player places item in the chest and clicks on the sign on the chest to sell all items in it, you can try this:

code_language.skript:
on rightclick on wall sign:
    if block at block under event-block is a chest or trapped chest:
        if line 1 of event-block is "&7[&6&lChestSell&7]":
            set {chestloc.%player%} to location of event-block
            loop all items in inventory of block at block under clicked block:
                remove loop-item from inventory of block at block under clicked block
This does not work
 
  • Like
Reactions: L0v0lup
Status
Not open for further replies.