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

Command every 15 minutes

Discussion in 'Skript' started by DitIsAndy, Sep 18, 2019.

  1. D

    DitIsAndy Member

    Joined:
    Sep 18, 2019
    Messages:
    1
    Likes Received:
    0
    I want to code a skript where a command is needed i wanted it to be when a player has played 15 minutes they get some cash/currency. what type of skript/command line do i need.
     
  2. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    271
    Likes Received:
    17
    Code (Skript):
    1. every 15 minutes:
    2.     # give player cash
    Ghetto way, it's not reliable since the counter in server-sided anyways it should do the trick :emoji_slight_smile:

    A good way would probably be:
    Code (Skript):
    1. on join:
    2.     while player is online:
    3.         wait 15 minutes
    4.         add 250 to {BALANCE::%player%}
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
    I recommend reversing the wait and the effect.
    IF the player logs off during this 15 minutes, the effect might throw an error.
    In this example you're only setting a var so its not a big deal, but if it were an effect that actually involved a player object, it will throw an error.

    Best practice is to use your effects first, wait after
     
  4. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    271
    Likes Received:
    17
    I didn't do it because of 2 reasons:
    1. I thought it would only do that while player is online
    2. Player can leave/join spam to get more money
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,049
    Likes Received:
    145
    1) The current iteration of the while loop will continue if the player logs out. If the player logs out, it just will stop the loop after the loop has finished
    2) Very valid point. In this case the dev would need to take extra precautions to make sure this doesn't happen.
     
    • Like Like x 1
  6. N

    ND_ Member

    Joined:
    Aug 3, 2019
    Messages:
    1
    Likes Received:
    0
    Code (Text):
    1. on join:
    2.     wait 15 minutes
    3.     while player is online:
    4.         add 250 to {BALANCE::%player%}
    5.         wait 15 minutes
     
Loading...