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.

block break event with custom block

Discussion in 'Skript' started by FallingCatus, Mar 23, 2019.

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

    FallingCatus Member

    Joined:
    Jun 29, 2017
    Messages:
    38
    Likes Received:
    0
    can someone tell me what i am doing wrong here? its not cancelling the event and is dropping the default block. I feel i am missing something simple here.

    thanks
    Code (Text):
    1. options:
    2.     block: light gray glazed terracotta
    3.     name: "&b&lGravity Generator"
    4.     lore: "&7This item restores earth like gravity."
    5.  
    6. on block place of {@block}:
    7.     if the 1st line of the tool's lore is {@lore}:
    8.         send "&dCosmic &8» &b&lGravity Generator &7has been placed." to player
    9.         stop
    10.  
    11. on block break of {@block}:
    12.     if the 1st line of the tool's lore is {@lore}:
    13.         cancel event
    14.         set event-block to air
    15.         wait 3 tick
    16.         give player 1 {@block} named {@name} with lore {@lore}
    17.         send "&dCosmic &8» &b&lGravity Generator &7has been removed." to player
    18.         stop
    19.     if the 1st line of the tool's lore is not {@lore}:
    20.         stop

    I am guessing its soemthing to do with storing block info, maybe like NBT but looking around a cant seem to find any real docs on it.
    any help will be awesome!
     
  2. Harvey

    Harvey Member

    Joined:
    Jan 16, 2018
    Messages:
    18
    Likes Received:
    0
    I replied to your discord message just going to paste it here:

    Seems to be working fine for me, except I just replaced the block you are using to dirt as I'm running 1.8 skript. In this case it might be the block you are using I'd recommend changing the block and seeing if it still does the same.
     
  3. FallingCatus

    FallingCatus Member

    Joined:
    Jun 29, 2017
    Messages:
    38
    Likes Received:
    0
    intresting, will check now
    --- Double Post Merged, Mar 23, 2019, Original Post Date: Mar 23, 2019 ---
    Just tried with dirt block and same issue, drops and dirt block with default name and lore and did not run the "give player 1 {@block} named {@name} with lore {@lore}"
     
  4. Harvey

    Harvey Member

    Joined:
    Jan 16, 2018
    Messages:
    18
    Likes Received:
    0
    Oh, yeah I made a mistake didn't realise you was asking why it wasn't cancelling the event if the name and lore wasn't correct. It's late and totally my fault.

    Explanation on why it doesn't work:
    You missed the "cancel event" bit from line 19 on. You only included a "stop" meaning it just stops the code if you want it to stop the event always add "cancel event", then after that put "stop" after stopping the code.

    Fixed code:
    Code (Text):
    1. options:
    2.     block: light gray glazed terracotta
    3.     name: "&b&lGravity Generator"
    4.     lore: "&7This item restores earth like gravity."
    5.  
    6. on block place of {@block}:
    7.     if the 1st line of the tool's lore is {@lore}:
    8.         send "&dCosmic &8» &b&lGravity Generator &7has been placed." to player
    9.         stop
    10.  
    11. on block break of {@block}:
    12.     if the 1st line of the tool's lore is {@lore}:
    13.         cancel event
    14.         set event-block to air
    15.         wait 3 tick
    16.         give player 1 {@block} named {@name} with lore {@lore}
    17.         send "&dCosmic &8» &b&lGravity Generator &7has been removed." to player
    18.         stop
    19.     if the 1st line of the tool's lore is not {@lore}:
    20.         cancel event
    21.         stop
    22.  
     
  5. Marsbar

    Marsbar Active Member

    Joined:
    Mar 31, 2019
    Messages:
    131
    Likes Received:
    4
    If hasn't found a way try with cancel the event
     
  6. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    use %event-location% and variables or maybe as you mentioned nbt
     
Thread Status:
Not open for further replies.

Share This Page

Loading...