Enderchests opening

  • 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 community!

    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.

hasanas

Member
Feb 7, 2017
12
0
0
Hey there!

I've been working on a script to supply lootcrates every so often on a number of set locations. everything works perfectly except that when a person clicks the enderchest, it also OPENS it instead of just give the items to the player. Can someone help me so it doesn't OPEN the enderchest but still gives the items, this is what I have right now:

Code:
variables:
    {rewards::1} = stick
    {rewards::2} = diamond
    {rewards::3} = apple

command /chestspawn <integer>:
    usage: /chestspawn <1-5>
    trigger:
        arg-1 is between 1 and 5:
            set {location.%arg-1%.chestspawn} to player's location
            send "Chestspawn %arg-1% created."
          
every 1 minute:
    set {_random} to a random integer between 1 and 5
    set block at {location.%{_random}%.chestspawn} to ender chest
    broadcast "Chest spawned at %{location.%{_random}%.chestspawn}%"

on rightclick on ender chest:
    loop integers between 1 and 5:
        clicked block's location is {location.%loop-number%.chestspawn}
        cancel event
    if {LootCrate.open} is true:
        message "&cSomeone else opened this crate already" to player
        stop
    else:
        set {LootCrate.open} to true
        wait 0.5 seconds
        give player a random item out of {rewards::*}
        launch burst firework colored blue at clicked block timed 0.1
        play mob spawner flames at the targeted block to the player
        wait 0.5 seconds
        set {LootCrate.open} to false

And there's a second problem, whenever I place a random enderchest, it treats it as if it was a spawned in one, like it also gives rewards from it.

Kind regards,
hasanas
 
code_language.skript:
on right click on ender chest:
    loop integers between 1 and 5:
        location of clicked block is {location.%loop-number%.chestspawn}
        cancel the event
        set {_success} to true
    {lootcrate.open} is not true:
        {_success} is true:
            set {lootcrate.open} to true
            wait 0.5 seconds
            open chest with 1 row named "Reward" to the player
            wait a tick
            add a random item out of {rewards::*} to player's current inventory
            launch burst firework colored blue at clicked block timed 0.1
            play mob spawner flames at the targeted block to the player
            wait 0.5 seconds
            delete {lootcrate.open}
    else:
        send "&cSomeone else opened this crate already"

NOT TESTED!
 
code_language.skript:
on right click on ender chest:
    loop integers between 1 and 5:
        location of clicked block is {location.%loop-number%.chestspawn}
        cancel the event
        set {_success} to true
    {lootcrate.open} is not true:
        {_success} is true:
            set {lootcrate.open} to true
            wait 0.5 seconds
            open chest with 1 row named "Reward" to the player
            wait a tick
            add a random item out of {rewards::*} to player's current inventory
            launch burst firework colored blue at clicked block timed 0.1
            play mob spawner flames at the targeted block to the player
            wait 0.5 seconds
            delete {lootcrate.open}
    else:
        send "&cSomeone else opened this crate already"

NOT TESTED!

Now it just does nothing at all when I click on an enderchest?

Code:
variables:
    {rewards::1} = stick
    {rewards::2} = diamond
    {rewards::3} = apple

command /chestspawn <integer>:
    usage: /chestspawn <1-5>
    trigger:
        arg-1 is between 1 and 5:
            set {location.%arg-1%.chestspawn} to player's location
            send "Chestspawn %arg-1% created."
           
every 1 minute:
    set {_random} to a random integer between 1 and 5
    set block at {location.%{_random}%.chestspawn} to ender chest
    broadcast "Chest spawned at %{location.%{_random}%.chestspawn}%"

on right click on ender chest:
    loop integers between 1 and 5:
        location of clicked block is {location.%{_random}%.chestspawn}
        cancel the event
        set {_success} to true
    {lootcrate.open} is not true:
        {_success} is true:
            set {lootcrate.open} to true
            wait 0.5 seconds
            open chest with 1 row named "Reward" to the player
            wait a tick
            add a random item out of {rewards::*} to player's current inventory
            launch burst firework colored blue at clicked block timed 0.1
            play mob spawner flames at the targeted block to the player
            wait 0.5 seconds
            delete {lootcrate.open}
    else:
        send "&cSomeone else opened this crate already"

Can you please help?
 
Had a fault inside the script, sorry.

change line 20 to:
code_language.skript:
"%location of event-block%" = "%{location.%loop-value%.chestspawn}%"
 
Status
Not open for further replies.