I am working on a 2X Exp developer product and the way I handled it was to use tick()
I save the sum of tick() of the time of purchase + the number of seconds for the game product to last.
Example code:
local playerkey = “user” player.userId
local expTime = math.floor(tick()) + 3600 — 1 hour worth of time
DataStore:SetAsync(playerkey, expTime)
After that, I have the code that determines the number of time left for double points by:
local initialTime = DataStore:GetAsync(playerkey)
if initialTime and initialTime - math.floor(tick()) > 0 then
print("Time left : " …initialTime - math.floor(tick()))
end
And the problem is that when I switch servers, the print output gives me completely different numbers. I know tick() constantly changes, but the difference I got from switching servers was from 3,000~ seconds to 10,000~ seconds. However, when I rejoined the server where the data was originally saved in, the difference went back to 3,000~ seconds.
Is the DataStore not saving numbers properly?
Or is the tick() giving me different values when I join different servers?
Nice, but can’t they then switch their operating system time to sometime in the past to bypass the expiration?[/quote]
os.time(), called server-side, returns the true UNIX time. I am unsure of client-side behaviour.
Edit, only time() and difftime() are accessible.[/quote]Yeah, I was surprised as well. Great to know they made those two functions usable.[/quote]
It would be really great if they also made date() accessible. Then we would be able to have special events during different days of the week. And possibly something like double points on weekends.