Zup Posted March 11, 2006 Share Posted March 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4669-phpmysql-game-programming/ Share on other sites More sharing options...
fenway Posted March 11, 2006 Share Posted March 11, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/4669-phpmysql-game-programming/#findComment-16352 Share on other sites More sharing options...
Zup Posted March 11, 2006 Author Share Posted March 11, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/4669-phpmysql-game-programming/#findComment-16359 Share on other sites More sharing options...
txmedic03 Posted March 11, 2006 Share Posted March 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4669-phpmysql-game-programming/#findComment-16369 Share on other sites More sharing options...
fenway Posted March 11, 2006 Share Posted March 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4669-phpmysql-game-programming/#findComment-16452 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.