Jump to content


Photo

PHP/MySQL Game Programming


  • Please log in to reply
4 replies to this topic

#1 Zup

Zup
  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationWinnipeg, MB

Posted 11 March 2006 - 04:59 AM

I am interested in creating a text-based game on the internet like Midnite Challenge, NY Mafia, Realthugz etc. However, I don't know how to keep the server updating itself. Games like this require constant updating, for example, a shop restocks, prices on commodities change, businesses open and close, etc. Say for example I want a particular store to be open from 9AM to 6PM. How would I make it so the server opens the store and closes the store at it's respective times?

Sorry if this is unclear. If anyone needs any clarification, please ask.

EDIT: Holy crap! Sorry for triple post. Someone please delete the other two.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 11 March 2006 - 05:44 AM

Well, until the 5.1 scheduler is up and running according to spec, I would recommend a cron job that runs periodically (e.g. hourly) and makes whatever DB changes are required. Of course, these changes could be stored in another DB, so that they can be easily changed without modifying the script (how ironic!). Make sense?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Zup

Zup
  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationWinnipeg, MB

Posted 11 March 2006 - 07:29 AM

Yea that does make sense. Now I have to learn how to make a cron job, but it can't be too hard. Thanks for your help.

BTW, would this help he out? [a href=\"http://www.phpfreaks.com/tutorials/28/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/28/0.php[/a]

#4 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 11 March 2006 - 08:11 AM

This assumes you are running linux. (crontab is a linux program) The alternative is to process in the script when the user loads the page. If time is between the hours to be open then they can access the shop otherwise shop is closed. Now this would be determined by the time set by the server unless you have users specify their local timezone and store the offset from the server in the MySQL database for users. Then take the offset into consideration and each individual user (whether they are in one timezone or another can access things according to their own local time. Rather than an american server with australians being up at 2:00 AM to go to a shop that's open during the day. That's just my two cents anyway.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.


#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 11 March 2006 - 05:04 PM

Yeah, that tutorial is fine. I would not suggest running such a script on EVERY page load -- it's extra work for the server to do, and most of the time, for no reason whatsover. Plus, it doesn't scale well at all. It will work, of course, but there are better ways to do it, even if you don't have crontab.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users