How to make Counter Timers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AmareshinO
Forum Newbie
Posts: 1
Joined: Tue Jul 29, 2008 9:36 pm

How to make Counter Timers

Post by AmareshinO »

Hi, im from brazil and my english is not so good.


So, Im creating an MMORPG with some friends.. all the ideas of the game are doned.

Maps, Tables (mySQL), and all the systens (Battle, Market, and others)

I need to know how can i use timers...

Expemple:

If i click in the link to upgrade my Factory to level 2, it uses some resources (Iron, Gas and Uranian) and need to the upgrade delays 1 hour to br completed. in this hour the player can calcel the upgrade.

and if the player is not connected when this hour ends, the site needs to make the function to upgrade the factory to level 2.


that's the better way that i found to explain my question.


any quesntion. ask me please...
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: How to make Counter Timers

Post by ghurtado »

Because during that hour PHP will not be running constantly, what you need to do is store the timestamp of when the upgrade gets started, then check it against the current timestamp everytime the user refreshes the page. If the difference is less than one hour, then the building / upgrade is finished. This is how most web based RPGs work, AFAIK.
Post Reply