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.

I need help with making my generator skript

Discussion in 'Skript' started by Derazzd, Nov 19, 2022.

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

    Derazzd Member

    Joined:
    Oct 21, 2022
    Messages:
    2
    Likes Received:
    0
    So, I've got it pretty much done, apart from if you spam break and place the generator, items will flood in from each time you placed it (only when the generator is placed), can someone help?
     

    Attached Files:

    • gen.txt
      File size:
      2.2 KB
      Views:
      25
  2. Pierrelasse

    Pierrelasse Active Member

    Joined:
    Apr 20, 2022
    Messages:
    116
    Likes Received:
    4
    this should do the job (btww its copied from another thread)

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

Share This Page

Loading...