#tracking days

1 messages · Page 1 of 1 (latest)

glass panther
#

Hi guys.

How can you achieve reliable day tracking on a server (real time, real days) ? By reliable, I mean that even if the server disconnects or experiences other issues, the timer continues running.

For example, let's say I have a function that collects data (statistics), and I want the statistics to be sent every week.

Thanks.

wraith hound
#
every 1 real second:
  add 1 to {time.%player's uuid%}
  if {time.%player's uuid%} is 84600:
    # stuff here
``` try this, dont know for sure
#

Cooldowns in cmds work so this may.

glass panther
wraith hound
#

Yeah, sure. To test it turn on your server make it send the time variable to you then look at the last time it sent you stop your server after 10 min turn your server on and check if it increased by 10 min, if not try every second: if still not, idk

delicate tulip
#

unix timestamp of now
Is the syntax

glass panther
delicate tulip
#

With unix, you don’t have to do an every second loop.

wraith hound
glass panther
#

Can you tell me what I'm doing wrong? I'm getting an error Can't understand this condition/effect: set {day} to UnixTimeStamp

  • And I get an error everywhere with this UnixTimeStamp

here is the code

    set {day} to UnixTimeStamp
    set {week} to UnixTimeStamp
    set {month} to UnixTimeStamp

function swk_timers(day: number, week: number, month: number):
    if {day} >= 86400:
        # код
        execute console command "/say day"
        # сброс
        set {day} to UnixTimeStamp
    if {week} >= 604800:
        # код
        execute console command "/say week"
        # сброс
        set {week} to UnixTimeStamp
    if {month} >= 2592000:
        # код
        execute console command "/say month"
        # сброс
        set {month} to UnixTimeStamp
    

every hour:
    swk_timers({day}, {week}, {month}) ```
bronze skiff
#

that's not the syntax he said

#

try:
set {day} to unix timestamp of now

lusty gull
#

you could do sonething like on load: set {lastOnline} to now and stuff,

#

then command /lastonline: send "%difference between {lastOnline} and now%"

glass panther
#

But how can you do a comparison of the two times "before" and "now" and checking should there be 86400 seconds(day) passed there

#

I've been racking my brain and couldn't come up with anything.

#

I hope it works.

    if (unix timestamp of now - {day}) >= 1:
        # code
        execute console command "/say %{day}%"
        # reset
        set {day} to unix timestamp of now
    if (unix timestamp of now - {week}) >= 604800:
        # code
        execute console command "/say week"
        # reset
        set {week} to unix timestamp of now
    if (unix timestamp of now - {month}) >= 2592000:
        # code
        execute console command "/say month"
        # reset
        set {month} to unix timestamp of now```