Timer Give Points Every 15 min

Hi guys, need help with something related timers and compare times between the game is closed and open again.

I have this logic:

For play my game you need use a Energy, when the game start you have 20 points and for play need 5…

My logic for use this energy work fine… every time when enter the game loose 5 points of energy and when that is 0 i cant play anymore.

312574-screenshot-18.jpg

Now my problem is this:

1 - Need regenerate this energy points 5 per 15 mins

2 - If you close the game without energy and open again after 15 min you recieve the 5 points.

Any can help me with some example or tutorial for make that?

Thx

BR

Do you have any more context for this kind of timer/game? If your talking about a system designed like many mobile games, in which the player slowly gathers energy throughout the day, those games are designed with a server/client mindset, and the energy gathering is done on the server side, which can basically be considered to always be on and running, or at least secure enough where they can record the time of the last energy tick, take the server offline for maintenance, and then bring it up and the system will check the time at last payout, current time, and figure out how long its been. This is to prevent individual players from gaming the system.

This is because you would need to store some piece of data that you can then test against to see how long it has been, this would mean recording local time, and then the next time the player loads the game it would check current time, last payout time, do some math and award missing energy. The problem with this is if the player changes their timezone, or advances the time manually,etc, they can cheese the system and get a lot more energy suddenly.

If your game is a generic single player only thing and your not concerned about people necessarily cheating, a simple solution would be to check out how to save/load game and store the data so that on load it checks and awards it: https://docs.unrealengine.com/en-US/Gameplay/SaveGame/index.html

@Okarii thx again for reply. My game is mobile and singleplayer… But i like the people see a rewarded video or buy energy. Need find the way the people not cheating.

There is a now node in unreal engine. If you use that, then break date time, you get a bunch of integers (the current day, the current year, minute, second, hour, millisecond).

This script will give you out the current date. You can set all of these as a variable when the game starts. Make them update every minute or so so it has the updated variables. You can do this with the delay node. Say event begin play, get the now node, and set the current year, month, day, and minute. Do the delay block for 30 seconds to 1 minute. After that, create a custom event, for example “getTimeLoop”. Then put get time loop into the update variables with the event begin play. It will look like this:

That will update you time variables every 45 seconds. You can then store these to a save game object, and use them to figure out how long it has been since the user was last on the game.

If the user is just playing the game, you can just use the delay node and set it to 15 minutes to do what you want every 15 minutes in the game

Let me know if you have more questions.

Hi @is.this.my.name, how are you?
This is needed set over the first level or over the level on the UMG where i have the bar like que first image?
Is possible set all over a CustomGameInstance and call over the BeginPlay on the Main Level?

After the Loop i can make here the logic to add the points to the energy correct?..

Another thing if store the value you mention after i need make a load the savegame where i store the time, correct?

What is the logic if close the game and open again? Checking your comments after save need load when open the game and i need compere the date stored with the actual correct?

Sorry a lot of questions jeje

Thx.

@is.this.my.name when you have time can check my questions? Thx…

@is.this.my.name are you there?