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.

How do I make it so players can only break a certain block that they placed?

Discussion in 'Skript' started by Derazzd, Oct 21, 2022.

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

    Derazzd Member

    Joined:
    Oct 21, 2022
    Messages:
    2
    Likes Received:
    0
    on place of hay block:
    if player's tool is hay block named "&e&lWheat Gen" with lore "&7-----&8-----" and "&7Produces wheat every 10 seconds" and "&7Upgrade cost: &e500⛃" and "&7-----&8-----":
    set {gens::%location of event-block%} to uuid of player
    if {gens::%player's uuid%} < 10:
    set {Ownblocks::%event-block's location%} to event-player
    add 1 to {gens::%player's uuid%}
    play sound "block.note_block.pling" at volume 1 at pitch 2 to player
    make 10 of poof at event-block
    while event-block is hay block:
    wait 80 ticks
    drop 1 wheat named "&e&lWheat" with lore "&7-----&8-----" and "&eWorth 10⛃" and "&7-----&8-----" above location of event-block
    else:
    send "" to player
    send "&bYou have reached your Gen Cap! &7%{gens::%player's uuid%}%&b/&710" to player
    send "" to player
    cancel event

    on break of hay block:
    if {Ownblocks::%event-block's location%} is not event-player:
    send "&cSorry, that is not your gen. You cannot break it."
    cancel event
    else if {Ownblocks::%event-block's location%} is event-player:
    set {Ownblocks::%event-block's location%} to false
    set {gens::%location of event-block%} to location of event-block
    remove 1 from {gens::%player's uuid%}
    set event-block to air
    play sound "block.note_block.pling" at volume 1 at pitch 1 to player
    make 10 of poof above event-block
    give player hay block named "&e&lWheat Gen" with lore "&7-----&8-----" and "&7Produces wheat every 10 seconds" and "&7Upgrade cost: &e500⛃" and "&7-----&8-----"



    This should be enough of the code, I've tried to use Ownblocks as I found that on another forum post, but it's not working can anyone help?
     
    • Funny Funny x 1
  2. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    139
    Likes Received:
    22
    thank you for readable format of code.
    upload_2022-10-21_20-55-58.png
     
    • Agree Agree x 1
    • Funny Funny x 1
  3. Pierrelasse

    Pierrelasse Active Member

    Joined:
    Apr 20, 2022
    Messages:
    116
    Likes Received:
    4
    POV that dude: No problem!

    Codddddddde:
    Code (Text):
    1.  
    2. on place of hay block:
    3.     if player's tool is hay block named "&e&lWheat Gen" with lore "&7-----&8-----" and "&7Produces wheat every 10 seconds" and "&7Upgrade cost: &e500⛃" and "&7-----&8-----":
    4.  
    5.         set {gens::%location of event-block%} to uuid of player
    6.  
    7.         if {gens::%player's uuid%} < 10:
    8.             set {Ownblocks::%event-block's location%} to event-player
    9.             add 1 to {gens::%player's uuid%}
    10.             play sound "block.note_block.pling" at volume 1 at pitch 2 to player
    11.             make 10 of poof at event-block
    12.             while event-block is hay block:
    13.                 wait 80 ticks
    14.                 drop 1 wheat named "&e&lWheat" with lore "&7-----&8-----" and "&eWorth 10⛃" and "&7-----&8-----" above location of event-block
    15.         else:
    16.             send "" to player
    17.             send "&bYou have reached your Gen Cap! &7%{gens::%player's uuid%}%&b/&710" to player
    18.             send "" to player
    19.             cancel event
    20.  
    21. on break of hay block:
    22.     if {Ownblocks::%event-block's location%} is not event-player:
    23.         send "&cSorry, that is not your gen. You cannot break it."
    24.         cancel event
    25.     else if {Ownblocks::%event-block's location%} is event-player:
    26.         set {Ownblocks::%event-block's location%} to false
    27.         set {gens::%location of event-block%} to location of event-block
    28.         remove 1 from {gens::%player's uuid%}
    29.         set event-block to air
    30.         play sound "block.note_block.pling" at volume 1 at pitch 1 to player
    31.         make 10 of poof above event-block
    32.         give player hay block named "&e&lWheat Gen" with lore "&7-----&8-----" and "&7Produces wheat every 10 seconds" and "&7Upgrade cost: &e500⛃" and "&7-----&8-----"
    33.  
    This should be enough of the code, I've tried to use Ownblocks as I found that on another forum post, but it's not working can anyone help?


    Ok after around 1 hour of hard work. (Many ppl have died) I got it working i think
    Code (Text):
    1.  
    2. # Contributors:
    3. #   - Pierrelasse#3737
    4. #   - Lolzy#7652
    5. #   - DeafMole#2930
    6.  
    7. on load:
    8.     set {-cache::wheatgen} to hay block named "&e&lWheat Gen" with lore "&7-----&8-----%nl%&7Produces wheat every 10 seconds%nl%&7Upgrade cost: &e500⛃%nl%&7-----&8-----"
    9.     set {-cache::wheatdrop} to wheat named "&e&lWheat" with lore "&7-----&8-----%nl%&eWorth 10⛃%nl%&7-----&8-----"
    10.  
    11.  
    12. on command:
    13.     if command is "ggen":
    14.         cancel event
    15.         give {-cache::wheatgen} to player
    16.  
    17.  
    18. on place of hay block:
    19.     event is not cancelled
    20.     if 1 of player's tool is {-cache::wheatgen}:
    21.  
    22.         set {_i} to 0
    23.         loop {gens::*}:
    24.             loop-value is player's uuid
    25.             add 1 to {_i}
    26.  
    27.         if {_i} > 10 -1:
    28.             send "%nl%&bYou reached your Gen-Cap! &7%{_i}%&8/&710%nl%"
    29.             cancel event
    30.  
    31.         else:
    32.             if {gens::%event-block's location%} is set:
    33.                 broadcast "&4%player% is tryin to exploit da system! or sum bug is ther"
    34.                 stop
    35.             set {gens::%event-block's location%} to player's uuid
    36.  
    37.             play sound "block.note_block.pling" at volume 1 at pitch 2 to player
    38.             make 10 of poof at event-block
    39.  
    40.             send "&aGen placed!"
    41.  
    42.  
    43. every 80 tick:
    44.     loop {gens::*}:
    45.         (loop-value parsed as player) is online
    46.  
    47.         set {_l::*} to loop-index split at ":"
    48.         set {_c::*} to {_l::2} split at ","
    49.         set {_loc} to location({_c::1} parsed as number,{_c::2} parsed as number,{_c::3} parsed as number, world {_l::1})
    50.  
    51.         set {_b} to block at {_loc}
    52.  
    53.         if type of {_b} is hay block:
    54.             drop {-cache::wheatdrop} above {_b} without velocity
    55.  
    56.         else:
    57.             clear {gens::%loop-index%}
    58.             send "[Gen] Removed gen from list since there is no gen!" to console
    59.  
    60.  
    61. on leftclick on hay block:
    62.     set {_e} to "%event-block's world%:%event-block's x-coord%,%event-block's y-coord%,%event-block's z-coord%"
    63.  
    64.     if ({gens::%{_e}%} parsed as player) is not player:
    65.         send "&cSorry, but you cant break gens from others!"
    66.         cancel event
    67.         stop
    68.  
    69.     if player is not sneaking:
    70.         send "&cPlease sneak to confirm removing the gen!"
    71.         stop
    72.  
    73.     clear {gens::%event-block's location%}
    74.     set event-block to air
    75.     give {-cache::wheatgen} to player
    76.  
    77.     send "&aGen destoryed!"
    78.     play sound "block.note_block.pling" at volume 1 at pitch 1 to player
    79.     make 10 of poof above event-block
    80.  
    81.  
    82. on block break:
    83.     event-block is hay block
    84.     cancel event
    85.  
     
    • Funny Funny x 1
  4. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    139
    Likes Received:
    22
    ты понимаешь, что ты поехавший???
     
    • Funny Funny x 1
  5. Pierrelasse

    Pierrelasse Active Member

    Joined:
    Apr 20, 2022
    Messages:
    116
    Likes Received:
    4
    ???? upload_2022-10-31_19-35-13.png
     
    • Funny Funny x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...