Crons Tutorial
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: crons
there are several ways, all a cron is, is a script, just use windows scheduler to run the script.
Re: crons
There may be better time based coding to do a specific player action with his own specific 12 hour timer. Unless you wanted to to check and then be around 12 hours and run the cron all the time. A cron is best used for things you want to automate in mass. Like lets say you want all your characters to regen health every 10 minutes or so a cron would run and set everyone's health up by a % or whatever. Same deal with action point type currencies and anything else you want a script to do on a set timer in mass.
If you wanted to do a server wide bonus of 10% attack a cron would be ideal for that. They're just not at a glance terribly useful for single player interactions. Creativity may solve that problem but, for the most part a cron is more or less just a script that runs on a timer and executes whatever the script tells it to.
If you wanted to do a server wide bonus of 10% attack a cron would be ideal for that. They're just not at a glance terribly useful for single player interactions. Creativity may solve that problem but, for the most part a cron is more or less just a script that runs on a timer and executes whatever the script tells it to.
Re: crons
I thought of a possible solution, but it has one major flaw. Ok heres the possible cron solution. When you use the item it sets a value in the system to 12 now the cron will take one value away each hour and when i need to use the bonus i'll set is so if bonus value is > 0 then you receive the bonus. The flaw is if someone uses the item right before the cron is ran then they might possibly loos a hour.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: crons
For "rolling hour" counters, checking it once an hour just won't work for the reason you gave. If it is just one global cron script that runs to check this for the whole database, then it doesn't matter too much if you run it once every hour, or once every 5 minutes. Crons really start to add up if you are running them many times a minute (or even a second), or a bit less if they are very resource intensive. Also, to make the logic work correctly with more checks, you would need to record the access times in the database, and have the cron script check to see if a certain period has passed, such as an hour. Since the script is not running only once per hour, an integer holding a basic value wouldn't be enough to determine the time frame.Dizuki wrote:I thought of a possible solution, but it has one major flaw. Ok heres the possible cron solution. When you use the item it sets a value in the system to 12 now the cron will take one value away each hour and when i need to use the bonus i'll set is so if bonus value is > 0 then you receive the bonus. The flaw is if someone uses the item right before the cron is ran then they might possibly loos a hour.
The indelible lord of tl;dr
Re: crons
Not sure how to do it exactly but you could try having it so when the item is activated it gets the current time and adds 12 hours and stores that as the time and the date it needs to stop running. If its a bonus to strength thats used for boosting attack say 30% then get it to check the time and if the item should still be active when you go to the arena/battle screen. Maybe having it so that if it is active then a little icon for it with a description somewhere too, I dont know if this would work but Im just tying to help out 

This isnt just a gimp mask...This is an S&M gimp mask...
Re: crons
I also looked at godaddy and they looked like a deal. Question, is their anyway to get them to cron more often? (I assume for a price.) I guess a sneaky way of getting more cron action is to have it run every time a user loads a page. (This would probably be a bad idea unless you knew how to only make them refresh things near the user's character; in general an idea but probably a bad one.)
Also I would love to have a godaddy tut.
How would you make.. say.. an NPC update on the server side?
Also I would love to have a godaddy tut.

How would you make.. say.. an NPC update on the server side?