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

Need help looping items in a chest and removing them

Discussion in 'Skript' started by Hassan7000, Mar 12, 2018.

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

    Hassan7000 Member

    Joined:
    Mar 12, 2018
    Messages:
    23
    Likes Received:
    3
    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 (Skript):
    1. on sign change:
    2.     if line 1 is "[ChestSell]":
    3.         set line 1 to "&7[&6&lChestSell&7]"
    4.         set line 2 to "&6&l%player%"
    5.         message "&aYou have created a ChestSell"
    6.        
    7. on rightclick on a chest or trapped chest:
    8.     if type of loop-block is wall sign:
    9.       if line 1 of loop-block is "&7[&6&lChestSell&7]":
    10.         set {chestloc.%player%} to location of loop-block
    11.         remove 1 sign from {_tmpchest}
    I have tried something here but its not working
    --- Double Post Merged, Mar 13, 2018, Original Post Date: Mar 12, 2018 ---
    bump
     
  2. Wynnevir

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    974
    Likes Received:
    57
    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 (Skript):
    1. loop all items in inventory of clicked block:
    2.     remove loop-item from event-block
    3.     #or perhaps
    4.     remove loop-item from inventory of clicked block
     
  3. H

    Hassan7000 Member

    Joined:
    Mar 12, 2018
    Messages:
    23
    Likes Received:
    3
    Didnt work can you help me fix this

    My code now
    Code (Skript):
    1. on rightclick on a chest or trapped chest:
    2.     if type of event-block is wall sign:
    3.         if line 1 of event-block is "&7[&6&lChestSell&7]":
    4.         set {chestloc.%player%} to location of event-block
    5.         loop all items in inventory of clicked block:
    6.             remove loop-item from inventory of clicked block
     
  4. Wynnevir

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    974
    Likes Received:
    57
    Signs do not have an inventory. You'll need to add the items to a list variable and then loop that
     
  5. H

    Hassan7000 Member

    Joined:
    Mar 12, 2018
    Messages:
    23
    Likes Received:
    3
    Can you try and show me how to do it the right way That would be a great help
     
  6. HackerOTVW

    HackerOTVW Well-Known Member

    Joined:
    Sep 10, 2017
    Messages:
    91
    Likes Received:
    1
    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 (Skript):
    1. on rightclick on wall sign:
    2.     if block at block under event-block is a chest or trapped chest:
    3.         if line 1 of event-block is "&7[&6&lChestSell&7]":
    4.             set {chestloc.%player%} to location of event-block
    5.             loop all items in inventory of block at block under clicked block:
    6.                 remove loop-item from inventory of block at block under clicked block
     
  7. H

    Hassan7000 Member

    Joined:
    Mar 12, 2018
    Messages:
    23
    Likes Received:
    3
    This does not work
     
    • Like Like x 1
  8. HackerOTVW

    HackerOTVW Well-Known Member

    Joined:
    Sep 10, 2017
    Messages:
    91
    Likes Received:
    1
    Does it have any errors?
    Or try replacing "wall sign" to "sign"
     
  9. H

    Hassan7000 Member

    Joined:
    Mar 12, 2018
    Messages:
    23
    Likes Received:
    3
    I fixed it instead of under clicked is behind clicked block
     
  10. HackerOTVW

    HackerOTVW Well-Known Member

    Joined:
    Sep 10, 2017
    Messages:
    91
    Likes Received:
    1
    And it worked ?
     
  11. H

    Hassan7000 Member

    Joined:
    Mar 12, 2018
    Messages:
    23
    Likes Received:
    3
    Yes thank you for your help
     
    • Like Like x 1
Thread Status:
Not open for further replies.
Loading...