Jump to content

Archived

This topic is now archived and is closed to further replies.

Zup

PHP/MySQL Game Programming

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.