Amy8
March 14, 2024, 4:35pm
1
Godot Version
Godot 4
Question
Hi, I want to make a game that every day when you open it you recived 100 points to play. A text box pops up and when you accept it, the points you had previously are added to the ones you had
How do I get them only once a day?
Are you ok with people closing the game, changing their date, then reopening it for more?
Edit: the reason I ask is because the answer can be easy or hard. Buy easier answers are cheatable. Which is ok if your fine with that.
Universally? Or only specific, common, types of this?
I dont think a daily surprise bad on principle.
What dont you like about it? What if it were optional?
I’ll leave the whole points and popup implementation to you. But you can use the Time singleton to check the current date:
Time.get_date_dict_from_system().day
Here is the documentation: Time — Godot Engine (stable) documentation in English
Amy8
March 15, 2024, 10:05am
6
That’s my problem I want the difficult way but I’m having a lot of troubles with it
Amy8
March 15, 2024, 10:09am
7
Yep, I have the code of the points system and also the pop up text but my trouble is that I want to show it just once every day. I know that I could do it with that code but I don’t want people to change the time. Thanks you anyway
In that case, you’ll probably have to connect to some online time server like this one: https://worldtimeapi.org/
Amy8
March 15, 2024, 10:20am
9
Okay! How can I do it? You know some tutorial about it? Is my first proyect and I have never connected it to an online server. Thanks you so much!
Sure, here is a good example of how you can do a call to the API: Making HTTP requests — Godot Engine (stable) documentation in English
So it would look something like this:
extends Node
func _ready():
$HTTPRequest.request_completed.connect(_on_request_completed)
$HTTPRequest.request("http://worldtimeapi.org/api/timezone/Europe/Brussels")
func _on_request_completed(result, response_code, headers, body):
var json = JSON.parse_string(body.get_string_from_utf8())
print(json["day_of_week"])
Amy8
March 15, 2024, 10:25am
11
Thanks you so much I’m gonna try it!!