Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Using os.time()? Outputting a giant number.

Asked by
dirk2999 103
6 years ago

So upon research I saw using os.time() is better than tick(). I haven't worked with either of them. I want to create a daily rewards system. I'm not exactly sure how to work with os.time() if someone can give me some insight. I did this to try to get an understanding and figure out the date/time.

print(os.time())

It outputted this, I have no idea how to work with that

1531602258

2 answers

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

os.time() returns the number of seconds since Jan 1, 1970. You can use os.date() instead.

Documentation

Ad
Log in to vote
1
Answered by 6 years ago

os.time is indeed the best way to create a daily rewards system. As Phantom stated, os.time() returns the number of seconds since the epoch, January 1st, 1970. It's a number that is always increasing. If you save the os.time() at which the player was last in the game, and then subtract it from the os.time() when they rejoin, you will be given the amount of time that they haven't been in the game, in seconds. Using this, you can check to see if they were gone long enough and, if they were, reward them.

Answer this question