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.

Solved Placing a chest with specified items in it

Discussion in 'Skript' started by RetroGamerSP, Jul 12, 2017.

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

    RetroGamerSP Member

    Joined:
    Jul 12, 2017
    Messages:
    21
    Likes Received:
    0
    Essentially i want to make a skript that when an item is used it will summon a chest in a 10 block radius of the player with pre specified items in it, when the items are taken out i need the chest to dissapear, currently i cannot find a way of doing any of the above

    could someone please help with this
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    This should work
    Code (Skript):
    1.  
    2. function chestSummon(player: player, radius: integer):
    3.     #here you get a random block
    4.     set {_block} to random element out of the blocks in radius 10 around {_player}
    5.     set {_block} to chest
    6.     #Here is where you add the items this is just an example
    7.     set slot 3 of {_block}'s inventory to diamond sword
    8.     #Here is where you check if the chest has items
    9.     while {_block} is a chest:
    10.         if items in {_block}'s inventory isn't set:
    11.             set {_block} to air
    12.         wait 1 tick
    13.  
    14. on rightclick:
    15.     chestSummon(player, 10)
    16.  
    Please mark as solved if this fixed ur problem
    This is untested!
     
    #2 ShaneBee, Jul 12, 2017
    Last edited by a moderator: Jul 12, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    when using this i get this error
    https://gyazo.com/eae8f83a9ffd655884125d6526edbabb
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    i just edited the code test now
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    still same issue with bools and text as above
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    What version of skript are u using?
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    2.1.2
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Use 2.2
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    where can i get the 1.8 version of 2.2? the drop box link on the wiki wont load for me
     
  10. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    This wont work anyways unless I'm mistaken because you're not actually choosing a random block, you're going to always be setting {_block} to true because you're only adding true to the list.

    You should be setting {_blocks::%loop-block%} to loop-block's location not true

    Or as pikachu pointed out in a previous post you should do this instead of loops for a random block:
    Code (Skript):
    1. set {_block} to random element out of the blocks in radius whatever around {_player}
     
  11. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    nvm got it
     
  12. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Ok, is edited now ty
    --- Double Post Merged, Jul 12, 2017, Original Post Date: Jul 12, 2017 ---
    P
    Pls mark as solved
     
  13. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    no i mean i got the version XD
     
  14. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    oh ok xD test it check the code is edited
    --- Double Post Merged, Jul 12, 2017, Original Post Date: Jul 12, 2017 ---
    the set to true is just to be sure that none of the blocks is repeated on the list variable
     
  15. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    ok no errors this time but the chest isnt being placed at all
     
  16. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Test this
    Code (Skript):
    1. function chestSummon(player: player):
    2.     #here you get a random block
    3.     set {_block} to random element out of the blocks in radius 10 around {_player}
    4.     broadcast "%{_block}%"
    5.     set {_block} to chest
    6.     #Here is where you add the items this is just an example
    7.     set slot 3 of {_block}'s inventory to diamond sword
    8.     #Here is where you check if the chest has items
    9.     while {_block} is a chest:
    10.         if items in {_block}'s inventory isn't set:
    11.             set {_block} to air
    12.         wait 1 tick
    13.  
    14. on rightclick:
    15.     chestSummon(player)
    And tell me what does the broadcast say
     
  17. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    doesnt say anything
     
  18. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    line 5 needs to be
    Code (Skript):
    1. set the block at {_block}'s location to a chest
     
  19. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    nvm it suddenyly started broadcasting the blocks in the area
     
  20. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    This should work
    Code (Skript):
    1. function chestSummon(player: player):
    2.     #here you get a random block
    3.     set {_block} to random element out of the blocks in radius 10 around {_player}
    4.     set block at {_block} to chest
    5.     #Here is where you add the items this is just an example
    6.     set slot 3 of {_block}'s inventory to diamond sword
    7.     #Here is where you check if the chest has items
    8.     while {_block} is a chest:
    9.         if items in {_block}'s inventory isn't set:
    10.             set {_block} to air
    11.         wait 1 tick
    12.  
    13. on rightclick:
    14.     chestSummon(player)
    --- Double Post Merged, Jul 12, 2017, Original Post Date: Jul 12, 2017 ---
    Yeah i forgot to change that part
     
Thread Status:
Not open for further replies.

Share This Page

Loading...