Jump to content

Archived

This topic is now archived and is closed to further replies.

xyn

Using time...

Recommended Posts

Hey Guys,
I have a small project, but my knowlege on MKTime(); and time(); is
pretty crap, could someone help me brush my skills on this.
Basically I am designing a small online text based game (un-original i know)

And for every 5 minutes i wanted a character to lose 1% hunger. but
I don't know what to do. My guess is...

To time stamp during the logged in time, and everytime the user views a page
the time stamp is updated, and then using mktime() (somehow)
take the time stamp, and check the current time if the current time is
5 - 10 mins longer than the last time stamp then take 1% hunger.
otherwise do nothing...

I might be barking up the wrong tree, any advice guys?
I apreciate it.

Share this post


Link to post
Share on other sites
Using PHP's time(); function would be fine. Store it like that in the db or session and then format later for display or comparison purposes.

Share this post


Link to post
Share on other sites
:/ Lol. how would i do this?
like...

time() + 10; or what ever? :/

To check every 10 minutes to last time updated.

Share this post


Link to post
Share on other sites
That wouldn't be the way to check it, no. I can't write the code for you...especially if you are going to charge or make money in any way off of this. If you plan on making this a business venture or a site that will generate income...you need to seriously invest some time into learning PHP.

Myabe this will point you in the right direction:

If you're storing the time in a database, you will need to use conditional statements and define the actions taken depending on the difference in time. You should store them as timestamps and then format them before doing the comparisons.

Take a look at :

http://us2.php.net/manual/en/function.time.php
http://us2.php.net/date

Share this post


Link to post
Share on other sites
yeh, this isn't a company and It is 100% free :/
Just something i'm doing for fun...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.