0

The idea is pretty simple:

Where the timer is made in Javascript, when it reaches zero it performs a query in PHP that alters the database value to add 1.

The problem is that the timer in question must not be reset with page refresh, just like any browser based game, when you build a new facility.

This is for a school game project, in which you click "Build" and depending on that facility's level it would take X time to upgrade it to a new level, showing a timer that tells the user how much time left until the upgrade is done.


I'm really sorry if the solution is somewhere here, but I swear to god I've searched everywhere but I could not get a decent methodology to do this.

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by sudeepjd
0

Hi El Pirata,

When the timer is activated, you could store a unix timestamp in a php session. Then if/when the user refreshes the page, you can check for a session (with the start time value) and continue counting down from there.

Hope this helps.

Jim :)

0

Adding on to Jim's reply, you would also need to calculate the (current time - time stored in session). This would give you the amount of time that the user has been playing. Deduct that from the total time to get the time remaining before the timer reaches 0.

Edited by sudeepjd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.