Daily Money

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

JohniClark

Member
Feb 19, 2017
31
2
0
25
Hello, i have coded a money system. but i want to make a function that gives a player money for his daily join. so the first join he does on a day will reward him with money. Is that possible? if yes how?
 
It's not the same, but you can do that he receives money once every 24 hours (That means that if he joins at 23:59 he will need to wait until 23:59 of the next day to get money again; he won't get money at 00:00 again.
code_language.skript:
on join:
    if {lastreward.%player%} is not set:
        set {lastreward.%player%} to now
        remove 24 hours from {lastreward.%player%}
    difference between now and {lastreward.%player%} is higher or equal to 24 hours
    add 50 to player's balance
    set {lastreward.%player%} to now
    stop


For what I belive there is no way to do an skript that runs once every real day. Yet.
 
It's not the same, but you can do that he receives money once every 24 hours (That means that if he joins at 23:59 he will need to wait until 23:59 of the next day to get money again; he won't get money at 00:00 again.
code_language.skript:
on join:
    if {lastreward.%player%} is not set:
        set {lastreward.%player%} to now
        remove 24 hours from {lastreward.%player%}
    difference between now and {lastreward.%player%} is higher or equal to 24 hours
    add 50 to player's balance
    set {lastreward.%player%} to now
    stop


For what I belive there is no way to do an skript that runs once every real day. Yet.
Dude Thats What i wanted! Thank You very Much! it works!
 
  • Like
Reactions: xUndefined
For what I belive there is no way to do an skript that runs once every real day. Yet.

You could do it by creating a daily money variable for each player that is cleared every day, like this:

code_language.skript:
on join:
    if {lastreward::%player%} is not set:
        add 50 to player's balance
        set {lastreward::%player%} to true
every hour:
    if hour is greater than 23: #hour 24 would be 12:00 AM, the start of a new day
        clear {lastreward::*}

That way, the player cannot get their daily money after a variable is simply updated to being true. When the new day starts, the 'lastreward' variable of every player is cleared, allowing them to get their reward regardless of when they logged in the previous day.
 
  • Like
Reactions: mc732
Status
Not open for further replies.