SunQuest
           Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesGame Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 21st, 2007, 10:08 AM
riaherod riaherod is offline
XxX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Manchester, UK.
Posts: 26 riaherod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 7 m 57 sec
Reputation Power: 0
Send a message via MSN to riaherod
Exclamation 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

Reply With Quote
  #2  
Old February 21st, 2007, 10:27 AM
twistedtwig's Avatar
twistedtwig twistedtwig is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Horsham - England
Posts: 302 twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 4 h 34 m 19 sec
Reputation Power: 22
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.
__________________
Cheers

Twiggy - http://www.houseofhawkins.com

Reply With Quote
  #3  
Old February 21st, 2007, 11:52 AM
riaherod riaherod is offline
XxX
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Manchester, UK.
Posts: 26 riaherod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 7 m 57 sec
Reputation Power: 0
Send a message via MSN to riaherod
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

Reply With Quote
  #4  
Old February 22nd, 2007, 06:21 AM
mikey1090 mikey1090 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 38 mikey1090 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 47 m
Reputation Power: 3
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

Reply With Quote
  #5  
Old July 19th, 2007, 08:56 AM
leeyew leeyew is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Location: Cumberland Md
Posts: 4 leeyew User rank is Sergeant (500 - 2000 Reputation Level)leeyew User rank is Sergeant (500 - 2000 Reputation Level)leeyew User rank is Sergeant (500 - 2000 Reputation Level)leeyew User rank is Sergeant (500 - 2000 Reputation Level)leeyew User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 2 m
Reputation Power: 0
Send a message via AIM to leeyew Send a message via Google Talk to leeyew
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.

Reply With Quote
  #6  
Old August 12th, 2007, 08:41 PM
mr.mofo mr.mofo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 102 mr.mofo User rank is Lance Corporal (50 - 100 Reputation Level)mr.mofo User rank is Lance Corporal (50 - 100 Reputation Level)mr.mofo User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 13 h 16 m 12 sec
Reputation Power: 3
Send a message via AIM to mr.mofo
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > Online Game - Quick PHP/MySQL Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway