hey everyone, well i wanted to make a game that uses time like for example every 24 hours if this person owns a store, they get paid 125 gold. How would you implement this? thanks guys!
~baseball435
Using time with php and mysql
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
- PaxBritannia
- Posts: 680
- Joined: Sun Apr 18, 2010 1:54 pm
Re: Using time with php and mysql
Use a cron or alternative to run a script that checks for whoever owns a store every 24 hours and give them the gold.
pax.
pax.
Re: Using time with php and mysql
Yeah, I'd store time() in some part of the database and then whenever a player logs in, it checks if a day or more has passed since the last storage of time(). If so count the number of days that have passed and go through the database with a while statement, adding gold to those with stores.
Or use a cron. I'm not familiar with them so I dunno.
Or use a cron. I'm not familiar with them so I dunno.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Using time with php and mysql
If you are actually looking for the ways to actually evaluate and deal with time calculations, I suggest to read this page of the PHP manual. It is mildly helpful, but there are a lot of good comments down the page. The very first comment has a working script for doing calculations to compare the current time with an existing timestamp.
The indelible lord of tl;dr

