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

How would I create a daily log in system?

Asked by 5 years ago

So I have a small idea about how it might work, for example: when a player joins, use a special built in function to get their current real time date, and save it when they leave, and when they join the next day, check if the current date is different to the last saved date (as time can only go forwards I guess?) and if it is, proceed to the awarding procedure, and when they leave save said date again and repeat.

May someone clarify how I could achieve this?

1
Yea, you're right. But better that save os.time() then with maths get the player's date that he joined.  HaveASip 494 — 5y
0
Lovely stuff, thank you! Marmalados 193 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Hey Marmalados,

Issue

Just saying, don't save it every time they leave or you will be wanting them to be logged off for a whole day rather than come back the next day.

Clarification:

How about this, you save it when it is the first time ever that they are playing the game(So, when you find that they don't have any saved data), and then every time they join just check if the current time minus the time that you've saved last time they joined equates to 1 day. Then, if it does you can re-update the time that you saved for them with the current time and give them the daily login bonus or whatever.

I hope I helped and have a nice day.

Thanks,

Best regards,

KingLoneCat

0
I never considered that part! Thank you so much! Marmalados 193 — 5y
0
No problem. KingLoneCat 2642 — 5y
0
You'd want to test if the difference in time is equal *or greater* than a full day. Otherwise you'll have to connect at the exact second to get your rewards. Link150 1355 — 5y
0
Yeah, but you'll also have to make sure that it's not as great as 2 days or more. So, check if it's greater than or equal to a day but, less than a day * 2. KingLoneCat 2642 — 5y
Ad

Answer this question