Once Per 24-hour timestamp

Good day, GDevs,

I am looking for a way to save the current timestamp when a variable is turned on. After a certain amount of time and after a voice sample, the game is set up to shut off automatically through another variable.

However, I am looking for a way to prevent the end user from accessing a certain feature for 24 hours if they decided to load the application right afterward.

Basically, I want to limit how many times the end user will be able to perform the action until 24 hours have passed (which they will receive a prompt for if the actual time is below that).

Is this possible in GDevelop or is there a simpler way to achieve it? I am tinkering with the save and load feature but I am not sure I am doing it properly, particularly the equation to compare the times.

(Sorry about the line in the screenshot that says Time (“sec”). I know “timestamp” goes there but I was testing out something else when I screenshot the display.)

Write Point

Time Load Point to compare

Thanks for reading,

Hello, it’s an interesting topic for me but my solution won’t be the most elegant offered because I’m new to game making. But it might give you some ideas and it was fun to work on so here.
I created an event that only happens if the global variable timeleft is 0 (first time player) or is less than the current timestamp. The text on a failed try displays how many seconds is left, which is quite a large number if there is a lot of time left so you’d have to work on that to your liking.
The event on a successful try changes the timeleft variable to the current timestamp+86400000 milliseconds, and also deletes the old storage group and writes a new one. I’m not sure if deleting an old group first is necessary, I’ve been wanting to ask here but not wanting to look stupid heh.

Looking at it now I don’t even think you’d need to add the condition if it’s 0 because that would still be less than the current timestamp.

1 Like

Thank you for your reply. It’s funny how I I can be so much into Gdevelop and my brain suddenly goes into autopilot and I am staring at the wall for 20 minutes while whispering, “How do I do that part?”

I’ve got a few areas like that in my current project, to the point where I’m just working on other parts of the project while avoiding them lol.

1 Like

You can use Time(“timestamp”) expression to get the value of the windows system clock in milliseconds. Then, use storage to save this value to disk so that when the user opens the game again, you can load it to find out what the windows time was the last time they were in the game. Based on the difference between current and previous time, you can find out how many milliseconds passed since the user last started the game.

I tested it out using these events and I think it might work for you


The cheat to this is the player can change their system clock in windows to jump time ahead. I don’t know how to get around that but most players wouldn’t bother that much with it I think

1 Like

Thank you for your reply as well. I appreciate your efforts to help me to get my mind on the right track. Greatly appreciated. Have a good day.