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.

Money Generator

Discussion in 'Skript' started by Jerooski, May 22, 2020 at 4:51 AM.

  1. Jerooski

    Jerooski Member

    Joined:
    Apr 19, 2020
    Messages:
    12
    Likes Received:
    0
    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 (Text):
    1. on place:
    2.     set {_location} to event-location
    3.     if type of event-block is gray glazed terracotta:
    4.         set {generators::%{_location}%} to {_location} #save location
    5.         send "&6&l(!) &eTier I Generator has been placed!" to player
    6.         while player is online:
    7.             while block at {_location} is a gray glazed terracotta:
    8.                 wait 5 seconds
    9.                 add 1 to player's balance
    10.     else if type of event-block is air:
    11.         delete {generators::%{_location}%}
    12.         send "&6&l(!) &eTier I Generator has been removed" to event player
     
  2. 10splaya

    10splaya Member

    Joined:
    Jun 13, 2017
    Messages:
    15
    Likes Received:
    0
    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 (Text):
    1. on join:
    2.     while player is online:
    3.          if block at {_location} is a gray glazed terracotta:
    4.             do stuff
    5.  
    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
     
Loading...