[REQ]implementing time in stats
[REQ]implementing time in stats
Hi Lads
This is my first post here so at the begging i want so say that you are doing a great job!
Since i remember ive always wanted to make games, but life went the other way Ive been watching tuts about making Browser-Based MMORPG lately and learning PHP almost from scratch. I am trying to build this general image of the game i want to make and make sure i got all "php" parts covered but there is a lot to ask about ;P
Well, mainly i want to ask how to implement time-flow i the game. What i mean:
I want to use something like "stamina" and every action you want to make (attack or training) would use stamina points. You could refresh stam with a potions, but that was covered. But i want stam to refresh by itself lets say 1 point every 3min and i not so sure how to do that.
Could some1 throw me an idea for that, and maybe some small counter
This is my first post here so at the begging i want so say that you are doing a great job!
Since i remember ive always wanted to make games, but life went the other way Ive been watching tuts about making Browser-Based MMORPG lately and learning PHP almost from scratch. I am trying to build this general image of the game i want to make and make sure i got all "php" parts covered but there is a lot to ask about ;P
Well, mainly i want to ask how to implement time-flow i the game. What i mean:
I want to use something like "stamina" and every action you want to make (attack or training) would use stamina points. You could refresh stam with a potions, but that was covered. But i want stam to refresh by itself lets say 1 point every 3min and i not so sure how to do that.
Could some1 throw me an idea for that, and maybe some small counter
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [REQ]implementing time in stats
Check out Halls' tutorial video on crons, a Linux feature that allows you to set up specific scripts to run at certain time intervals. You could just set the script to add 1 to everyone's stamina every 3 minutes, but make sure you don't put them past their maximum.
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: [REQ]implementing time in stats
yep and if you dont have crons available you can go the less sexy route of setting up a time field in the players table that when the player is playing it checks to see if that time is reached. If so it gives stamina and sets the time back to another 30 minutes ahead.
Make sure to give stamina for every 30 minute incriment that happened as well be subtracting current time from stored time then dividing by 30.
Make sure to give stamina for every 30 minute incriment that happened as well be subtracting current time from stored time then dividing by 30.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [REQ]implementing time in stats
Hey Halls, have you ever thought of making a follow-up to the crons video that would show the major alternative (the "on-view" method)? I know some people either don't like using a completely different method when developing on Windows (Task Scheduler), don't have crons available on their host, or don't like the fact that a major part of their game is being handled by the OS instead of the web server software.
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: [REQ]implementing time in stats
hmm good idea, I will make it in the next video
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [REQ]implementing time in stats
Awesome I bet that will help out a lot of folks. People around here seem wary of crons because you can't test them on Windows the same way they will work on the server.
The indelible lord of tl;dr
Re: [REQ]implementing time in stats
Yeah, I tip toed around crons and developed my own on view method. I think when I feel more confident in future, perhaps on a latter project, I'll go for crons. They don't look hard, but when your starting out just missing a semi colon somewhere makes your code crash and burn, so your afraid of going for any extra layer of unknown complexity.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: [REQ]implementing time in stats
I am working on the videos now. Almost done but mic went out so buying another one.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [REQ]implementing time in stats
The universe is conspiring against you. Don't let it win!hallsofvallhalla wrote:I am working on the videos now. Almost done but mic went out so buying another one.
The indelible lord of tl;dr