I need help with making my generator skript

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

  • 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.

Derazzd

Member
Oct 21, 2022
2
0
1
22
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?
 

Attachments

  • gen.txt
    2.2 KB · Views: 120
this should do the job (btww its copied from another thread)

Code:
# Contributors:
#   - Pierrelasse#3737
#   - Lolzy#7652
#   - DeafMole#2930

on load:
    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-----"
    set {-cache::wheatdrop} to wheat named "&e&lWheat" with lore "&7-----&8-----%nl%&eWorth 10⛃%nl%&7-----&8-----"


on command:
    if command is "ggen":
        cancel event
        give {-cache::wheatgen} to player


on place of hay block:
    event is not cancelled
    if 1 of player's tool is {-cache::wheatgen}:

        set {_i} to 0
        loop {gens::*}:
            loop-value is player's uuid
            add 1 to {_i}

        if {_i} > 10 -1:
            send "%nl%&bYou reached your Gen-Cap! &7%{_i}%&8/&710%nl%"
            cancel event

        else:
            if {gens::%event-block's location%} is set:
                broadcast "&4%player% is tryin to exploit da system! or sum bug is ther"
                stop
            set {gens::%event-block's location%} to player's uuid

            play sound "block.note_block.pling" at volume 1 at pitch 2 to player
            make 10 of poof at event-block

            send "&aGen placed!"


every 80 tick:
    loop {gens::*}:
        (loop-value parsed as player) is online

        set {_l::*} to loop-index split at ":"
        set {_c::*} to {_l::2} split at ","
        set {_loc} to location({_c::1} parsed as number,{_c::2} parsed as number,{_c::3} parsed as number, world {_l::1})

        set {_b} to block at {_loc}

        if type of {_b} is hay block:
            drop {-cache::wheatdrop} above {_b} without velocity

        else:
            clear {gens::%loop-index%}
            send "[Gen] Removed gen from list since there is no gen!" to console


on leftclick on hay block:
    set {_e} to "%event-block's world%:%event-block's x-coord%,%event-block's y-coord%,%event-block's z-coord%"

    if ({gens::%{_e}%} parsed as player) is not player:
        send "&cSorry, but you cant break gens from others!"
        cancel event
        stop

    if player is not sneaking:
        send "&cPlease sneak to confirm removing the gen!"
        stop

    clear {gens::%event-block's location%}
    set event-block to air
    give {-cache::wheatgen} to player

    send "&aGen destoryed!"
    play sound "block.note_block.pling" at volume 1 at pitch 1 to player
    make 10 of poof above event-block


on block break:
    event-block is hay block
    cancel event
 
Status
Not open for further replies.