Money Generator

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

Jerooski

Member
Apr 19, 2020
16
0
0
25
I'm trying to make it so every time a player places a gray glazed terracotta (money generator), it gives them $1 every 5 seconds, I want that very specific placed block to be bound to the player, so when builders destroy gray glazed terracotta it doesn't send them a message, and also, for the $1 to be added only when the player is online.

This code I got seems to just crash the server when the player who placed the block goes offline.
Code:
on place:
    set {_location} to event-location
    if type of event-block is gray glazed terracotta:
        set {generators::%{_location}%} to {_location} #save location
        send "&6&l(!) &eTier I Generator has been placed!" to player
        while player is online:
            while block at {_location} is a gray glazed terracotta:
                wait 5 seconds
                add 1 to player's balance
    else if type of event-block is air:
        delete {generators::%{_location}%}
        send "&6&l(!) &eTier I Generator has been removed" to event player
 
The reason why it is crashing is due to you using 2 while loops (nesting). This will always crash a server. Best bet for you is to due an on join event as soon below:


Code:
on join:
    while player is online:
         if block at {_location} is a gray glazed terracotta:
            do stuff

I think yaml will be the best bet to keep the location of the event-block if you want it to be per player. If you what the generator to just work then the on join will help you reduce the lag.

If you have any questions, feel free to ask or even join the Discord for faster replies!!

- 10splaya
 
if you want more blocks to place i think a list would be good iot doesnt lag i would do this
on place of gray glazed terracotta:

add location of event-block to {machines::%player%}

every 10 seconds:
loop all players:
loop {machines::%loop-player%}
add 10 to loop-player's balance
add what u want this is just a concept
 
Status
Not open for further replies.