So i’m planning to make it so if players join the game before a certain date (12/17/18), they get a reward. I know I have to use os.time() but what i’m stuck on is the fact that everyone is in different time zones.
How do I calculator how much time is left (in seconds) to the date 12/17/18 with respect to current time zone??
That would be not so secure. Why don’t you just use it on the server and tell the client? Doing it the other way is insecure and extra work for no reason.
The best solution in this scenario is to simply base it all off one timezone. Players won’t care too much unless they are joining last minute, in which case simply adding a simple ‘EST’ to the time or whatever will do. The extra work isn’t necessary, and there is no way to guarantee security for sure. There is also no way to tell what timezone a player is in, and even if they inputted that manually (with verification server side so their timezone isn’t like UTC-10000000:00 lol), it’s just not worth the effort on your end. Just make it clear what timezone the finish time is. This is an issue other big companies have had to solve (such as Digital Extremes, the creator of Warframe), and they did it just by doing what I said and making it in one set timezone.
Save in the player data something called “LastRewardTick”, and the value is simply the last Tick() taken, when a player enters the game, subtract Tick() - LastRewardTick, and it will give you the seconds that have passed during the last Tick(), do the math to figure out how many hours is, then give to the player the reward, and update LastRewardTick.
I found this the best and easiest way, and if the player changes his time it will not affect the Tick().
EDIT: If you don not now what is Tick(), is how much time has elapsed since January 1st, 1970 .
You will have to manually offset the number of seconds gotten from either a server tick or os.time. All such time functions are UTC only, so it’s up to you to calculate the difference between UTC and EST in seconds, then offset the value. How, I have no clue.
I’m not answering your question about how to use os.time in according to EST timezone, I’m just saying you can use Tick(). Anyway, Tick() 1545886800 is equivalent to 12/27/18 12:00 am EST timezone
EDIT: Sorry, 1545800400, this is equivalent to 12/26/18 12:00 am EST, 24 hours before, I hope I haven’t confused you with so many numbers.