Jump to content


Photo

Using time...


  • Please log in to reply
4 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 01 September 2006 - 10:12 PM

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.

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 01 September 2006 - 10:33 PM

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.
PHP Ninja

#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 01 September 2006 - 10:44 PM

:/ Lol. how would i do this?
like...

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

To check every 10 minutes to last time updated.

#4 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 01 September 2006 - 11:08 PM

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/m...nction.time.php
http://us2.php.net/date
PHP Ninja

#5 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 01 September 2006 - 11:23 PM

yeh, this isn't a company and It is 100% free :/
Just something i'm doing for fun...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users