How do i compare time between game sessions ?

0 favourites
  • 3 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hello, I want to compare the last time the player played the game and the current time for an offline reward based on the second from the last session like if someone has been "offline" for 3 hours i would use 3hour * 60 minutes * 60 seconds for a variable that gives that player a reward like 1coin for each second offline.

    If somebody know how to do it or a plugin that could help me ?

    Thank <3

  • I had the same exact problem, so I had to make a little system using the UTC time plugin (It's included in the project), where when the app is quit, it saves the current time and when you enter the game again it compares the time, and calculates stuff. I have that system setup in the file, it's pretty easy, just analyze it a bit and I'm sure you'll be able to take it and adjust it to your needs. I hope it helps.

    (I have marked two comments in Red, and in between them is the code you need)...

    What the code does: Basically when the Game Suspends it saves the current time into the variables and then when you enter the game starts On Start Of Layout it calculates the time passed in Seconds and puts it into a variable called timePassed. Then you can use timePassed to calculate the size of the reward while you were offline or if a day has passed (timePassed > 86400) (86,400 seconds = 24 Hours) give the player the daily reward.

    drive.google.com/file/d/18rKyFUxl3f5NvXrhdVn4UnAPgeyyhhKM/view

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks <3

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)