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

how do I do a devproduct that lasts 7 days?

Asked by 6 years ago

How can I do a devproduct that lasts 7 days, for example: the player buys the devproduct that gives him a tool and after spending 7 days or the days that the tool proposes disappears and the player to have the tool again will have to buy from again the devproduct ... if someone helps me how I would do that, with a small example or something to look for in the wiki to guide me ... Thanks!

1 answer

Log in to vote
1
Answered by 6 years ago

I can't write you a script cause I'm not good enough but I do have some thing to share to you about this problem.

os.time

os.time is exactly what you need. More info about this can be found here

Basically, it tells the UNIX time in seconds that is always counting, even if the player is offline. By using this script:

local timetable = {year = 2018, month = 6, day = 2}
local timetable2 = {year = 2018, month = 6, day = 9}
local ostime = os.time(timetable)
local ostime2 = os.time(timetable2)

local difftime = os.difftime(ostime2, ostime)

print(difftime)

we can say that 1 week = 604800 seconds.

By using that information we can just use this logic.

When the player buys, it triggers a countdown using os.time that is going for 604800 seconds. When the countdown is over, delete the tool from the player.

Sorry if I can't write you a script, this whole thing is pretty advanced. But I hope you get the idea of where this script is going to be :)

0
I'm going to investigate about this, thank you very much! : D xmaanzach 28 — 6y
Ad

Answer this question