How I make daily rewards? Help

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.

1 Like

when i run into a game that “rewards” me for playing, i immediately uninstall.

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

3 Likes

That’s my problem :disappointed: I want the difficult way but I’m having a lot of troubles with it

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/

3 Likes

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"])
3 Likes

Thanks you so much :sob: I’m gonna try it!!