The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Game Development
|
Online Game - Quick PHP/MySQL Question
Discuss Online Game - Quick PHP/MySQL Question in the Game Development forum on Dev Shed. Online Game - Quick PHP/MySQL Question Game Development forum covering non language specific programming - game creation, design, modding, theories and math. A place for developers and gamers of all levels to discuss and debate all things involved in game creation and modding.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 21st, 2007, 10:08 AM
|
|
XxX
|
|
Join Date: Feb 2004
Location: Manchester, UK.
Posts: 26
Time spent in forums: 8 h 7 m 57 sec
Reputation Power: 0
|
|
Online Game - Quick PHP/MySQL Question
Hey there,
I am quite desperate for help with this small PHP problem!
I am creating an online game in PHP and have almost completed the script, although there are a few small things that I just can't seem to figure out.
Within the game each user has a character, which is interactive (can be fed, played with, etc). Each character has it's own statistics (Hunger, Intelligence...).
I have written the script that updates these stats if the user interacts with their character (feeds it) and that works great, but now I need to write the script that depreciates the stats regularly without the user logging in.
To simplify, if the user does not log in for two weeks, their character will grow more and more hungry each day until it is starving.
If anyone has any ideas on the best way to write this in php then I would be extremely grateful.
I hope this makes sense...
Thanks in advance,
Ria x
|

February 21st, 2007, 10:27 AM
|
 |
Contributing User
|
|
Join Date: Nov 2004
Location: Horsham - England
|
|
|
don't know exactly how to do them but could set up a cron job to run each day that does what you want. it can run a script to do this.
or have a DB table that holds the last they feed their character and when they log back on update it then.
|

February 21st, 2007, 11:52 AM
|
|
XxX
|
|
Join Date: Feb 2004
Location: Manchester, UK.
Posts: 26
Time spent in forums: 8 h 7 m 57 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by twistedtwig don't know exactly how to do them but could set up a cron job to run each day that does what you want. it can run a script to do this.
or have a DB table that holds the last they feed their character and when they log back on update it then. |
Thankyou for this - these are great ideas...you know what it's like when the answer is obvious but you have a coding overload...
Thanks again
|

February 22nd, 2007, 06:21 AM
|
|
Contributing User
|
|
Join Date: Feb 2006
Posts: 60
Time spent in forums: 6 h 33 m 35 sec
Reputation Power: 8
|
|
|
you need a field in the database that records each time the user logs in
then you need a php script to check if the user log in time is a long time ago(ask for help in php forum) and if so, increase their hunger etc
mike
|

July 19th, 2007, 08:56 AM
|
|
Registered User
|
|
Join Date: Jul 2007
Location: Cumberland Md
|
|
|
Just to throw this out there, as something i had done for my own game im working on, i had a page, that when i ran my website, i would open a sort of admin page for my site, this admin page had a feature that i had auto refresh that spot and run a certain script, i used javascript to do this to just simply refresh and keep rerunning the page. This allowed things to be incremented from time to time, such as if the page i have refreshes and increases a certain number by 1(or w/e) every hour, then have that effect things (such as in my case) i had it affect the amount of resources players generated useing buildings they had built. This allowed players to generate resources, while not being online to run the script.
|

August 12th, 2007, 08:41 PM
|
|
Contributing User
|
|
Join Date: Aug 2005
Posts: 102
 
Time spent in forums: 1 Day 13 h 32 m 10 sec
Reputation Power: 8
|
|
|
For what he is asking doing it in PHP and then setting it up as a cron job would be the best thing. Unless you know another language like java or perl you could write a script to continually check, or just as a cron job.
Don't forget you need to think about the future, so if you were to run checks on all your users through accessing a certain page it may time out or generate errors if you had tons of users. Or what happens if you go on vacation or get sick for a couple weeks? Then the "automation" won't happen.
__________________
We Live; We Love. We Hate; We Die.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|