Dates and such

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

Farid

Active Member
Feb 5, 2017
179
11
18
23
So I'm trying to make a script for a friends of mine, and I cannot think how I should do the structure yet.

Basically, I'm trying to record how long the player has been on the server, which is the easy part I can do myself, but the hard part is the fact that I need to make sure how long the player was on during today, this week, last week and this month.

So if you have any idea how I should code this please let me know, because I cannot think of a way right now.
 
code_language.skript:
on script load:
    if {server_day_timer} is not set:
        set {server_day_timer} to now
    if {server_week_timer} is not set:
        set {server_week_timer} to now

    while true is true: #idk if this actually works
        if difference between {server_day_timer} and now is greater than 1 real day:
            delete {timer::day::*}
            set {server_day_timer} to now
   
        if difference between {server_week_timer} and now is greater than 1 real week:
            delete {timer::week::*}
            set {server_week_timer} to now
        wait 1 second

on join:
    if {timer::day::%player%} is not set:
        set {timer::day::%player%} to now

    if {timer::week::%player%} is not set:
        set {timer::week::%player%} to now
something like this should work. rinse and repeat for longer time frames
 
  • Like
Reactions: Farid
code_language.skript:
on script load:
    if {server_day_timer} is not set:
        set {server_day_timer} to now
    if {server_week_timer} is not set:
        set {server_week_timer} to now

    while true is true: #idk if this actually works
        if difference between {server_day_timer} and now is greater than 1 real day:
            delete {timer::day::*}
            set {server_day_timer} to now
  
        if difference between {server_week_timer} and now is greater than 1 real week:
            delete {timer::week::*}
            set {server_week_timer} to now
        wait 1 second

on join:
    if {timer::day::%player%} is not set:
        set {timer::day::%player%} to now

    if {timer::week::%player%} is not set:
        set {timer::week::%player%} to now
something like this should work. rinse and repeat for longer time frames


Thanks, I kinda got the idea, I'll try it out soon.