|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Chop Chop
|
PHP Game Questions
Hey all! I have been working on creating a MMO game in PHP using MySQL databases, and I need some help. The game will be turn based, meanin that when a player does something (i.e. attacks) it takes a certain number of turns. When someone registers, they have 75 turns. I need a way to give the player 10 turns every hour, whether they are logged in or not. What is an easy way to do this?
__________________
Main Computer: Intel Core i5 2500K | AsRock Extreme3 Z68 | Corsair Vengeance 2 x 4GB DDR3 1600 | EVGA GTX460 768MB | Western Digital Caviar 750GB 7200RPM SATAII | Mushkin 60GB SSD w/ SRT enabled | Asus 20X DVD Burner | Antec 550W Modular | Cooler Master HAF 912 w/ 4 fans | NXZT Sentry Mesh fan controller | W7 | 2 x 23" LG IPS Monitors Laptop: Asus EEE 1000HE | 2GB RAM | Ubuntu Laptop: Lenovo Thinkpad T60p | 4GB RAM | W7 |
|
|
|
|
|
#2 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Just log the start time of their first move, the number of moves they have left, and the time of the last time you added moves. From there you can do a calculation of the number of hours elasped from their last move and add to their turns accordingly.
|
|
|
|
|
|
#3 |
|
Chop Chop
|
First move meaning what? How do I log the last move they made, get the time now, and what would the calcuation look like? I tried that, but I couldn't get it to work.
|
|
|
|
|
|
#4 |
|
Chop Chop
|
Anyone? Anyone at all?
|
|
|
|
|
|
#5 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
You really only need to log the last time you calculated how many moves they have left. From this time when you run the new calculation to see how many new moves they have, determine the number of moves from the old time.
Update the calculated time and you should be able to repeat this procedure. |
|
|
|
|
|
#6 |
|
Chop Chop
|
Again, what would these calcuations look like?
|
|
|
|
|
|
#7 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Don't know the functions off the top of my head, but PHP has an extensive collection of date/time functions. You can use these to determine the number of hours difference from one time to another.
|
|
|
|
|
|
#8 |
|
Member (2 bit)
Join Date: Mar 2005
Posts: 3
|
Here's a usefull function for you:
PHP Code:
![]() Notice: This may not be valid code. I used it just to show you the utility of the getmicrotime() function. I hope you get the ideea.
Last edited by radiopunk; 03-18-2005 at 10:11 AM. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|