Jump to content

PHP/MySQL Game Programming


Zup

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.
Link to comment
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?
Link to comment
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]
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.