Command every 15 minutes

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

DitIsAndy

Member
Sep 18, 2019
1
0
0
22
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.
 
code_language.skript:
every 15 minutes:
    # 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_language.skript:
on join:
    while player is online:
        wait 15 minutes
        add 250 to {BALANCE::%player%}
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
 
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
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
Reactions: malia
Code:
on join:
    wait 15 minutes
    while player is online:
        add 250 to {BALANCE::%player%}
        wait 15 minutes
 
  • Like
Reactions: Albe
Status
Not open for further replies.