Page 4 of 5

Re: crons

Posted: Tue May 04, 2010 1:27 am
by hallsofvallhalla
there are several ways, all a cron is, is a script, just use windows scheduler to run the script.

Re: crons

Posted: Thu Jul 15, 2010 2:54 am
by Dizuki
Can crons be used for functions like, if i use this item i get 10% attack bonus for the next 12 hours?

Re: crons

Posted: Thu Jul 15, 2010 4:12 am
by Rastan
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.

Re: crons

Posted: Sat Jul 17, 2010 4:25 am
by Dizuki
So what kind of time based thing would work for this, my game requires this for multiple features such as special bonuses, working, and a few other things.

Re: crons

Posted: Sat Jul 17, 2010 4:29 am
by Dizuki
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.

Re: crons

Posted: Sat Jul 17, 2010 4:43 am
by Jackolantern
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.
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.

Re: crons

Posted: Sat Jul 17, 2010 5:19 am
by Dizuki
So what would you suggest? I'm not onto doing crons yet but I'm making codes that will be relative to this and i'd rather have the plan done now then be stuck doing a extensive overhaul in the future.

Re: crons

Posted: Tue Aug 03, 2010 12:50 am
by neronix17
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 :D

Re: crons

Posted: Thu Aug 04, 2011 4:40 pm
by Animosity
I'm so very glad I clicked this video, I had not even thought about tyhings that automate a scheduled task, even though I play a browser based game that uses it often. I'm really glad you posted this Halls Thanks =)

Re: crons

Posted: Fri Aug 05, 2011 10:38 pm
by Articus
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. :D

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