DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • November 18, 2018, 10:13:50 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Cron Jobs/Time?  (Read 4311 times)
0 Members and 1 Guest are viewing this topic.
Avalon
Guest
« on: October 13, 2005, 07:14:39 AM »

I want to let a variable decrease by 1 for every account every day except when its 0, every day in real time that is. How do I achieve this? Is there any script like a cron job that runs every day? I am used to cron_day.php but i cant find anything alike in LOTGD
Logged
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5479



View Profile WWW
« Reply #1 on: October 13, 2005, 09:16:10 AM »

LoGD doesn't use cron jobs.  Your best method is to hook into newday_runonce.
Logged

Play the latest beta version here on DragonPrime
lonnyl
Guest
« Reply #2 on: October 13, 2005, 12:06:48 PM »

True LOGD does not use cron jobs.... However this does not mean that you cannot write a cron job for LOGD...

You would need to write your script to include the database settings, and would need to write the proper sql to perform the task that you would like.  Your script should also require a password to be passed to it before it will execute (to keep anyone from running it manually).  Then it is simply a matter of creating your cron job to load lynx with the proper url (passing the password so it executes).   It really shouldn't be too terribly hard to do.
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #3 on: October 13, 2005, 02:07:16 PM »

It really shouldn't be too terribly hard to do.

But, using the in-game functions would be a safer and more user-friendly method. Smiley
Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

Avalon
Guest
« Reply #4 on: October 13, 2005, 02:30:13 PM »

I agree on Sichae, but what about this newday_runonce, does it run once a day for all members or once a INGAME day?
And how would I make this variable decrease by one each day, in the easiest way?
Logged
Radioactivebloke
Guest
« Reply #5 on: October 13, 2005, 03:53:34 PM »

I agree on Sichae, but what about this newday_runonce, does it run once a day for all members or once a INGAME day?
And how would I make this variable decrease by one each day, in the easiest way?
Hook into newday_runonce or whatever, then for the decrease:
Code:
$variable--; #or
$variable-=1; #or
$variable = $variable-1;
Logged
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5479



View Profile WWW
« Reply #6 on: October 13, 2005, 04:14:24 PM »

newday_runonce occurs once every server newday.  Without a cron job, there is no way to guarantee running of your procedure once per real time day.
Logged

Play the latest beta version here on DragonPrime
Dannic
Guest
« Reply #7 on: October 13, 2005, 06:03:13 PM »

cron job files - You could also put the file outside your public tree to make it inaccessable to the web.  That way you wouldn't need to put password protection on it.  Just another thought on the cron job thing.  Smiley
Logged
Kendaer
Guest
« Reply #8 on: October 13, 2005, 09:56:22 PM »

newday_runonce occurs once every server newday.  Without a cron job, there is no way to guarantee running of your procedure once per real time day.

You are incorrect Talisman.

The newday-runonce hook will run once per real day *as long as* someone logs into the game during that real life day.

That is the primary difference between it and a cron job.  If you have a small enough server that you don't have a player who logs in at least once per real day you'll skip days with this.

The way you would use this woud be to write SQL which modified the table containing the variable you want to decrement, or you would iterate through all the players and do the modification.  Please note that the latter method could be time-consuming on a large server like central, so you probably want to take a care to be efficient.  However ANY large access to the accounts table (or any other big table) will be slow in the same way, EVEN if run through a cron-job and could easily (and likely) cause server slowdown at the time the script is running.

Basically you need to figure out how to do what you want to do and then hook it up via a module to the newday-runonce hook.   I suspect that missng a day if there are no players during that day is perfectly acceptable Smiley

Logged
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5479



View Profile WWW
« Reply #9 on: October 13, 2005, 10:05:31 PM »

You are incorrect Talisman.

The newday-runonce hook will run once per real day *as long as* someone logs into the game during that real life day.

That's why I said there was no guarantee - runonce is based on the assumption that at least one player logs in each day, which is not necessarily a given.   Wink

Although I suppose he could do some date math magic to ascertain whether any amount of real days had elapsed since the last player logged in.
Logged

Play the latest beta version here on DragonPrime
Avalon
Guest
« Reply #10 on: October 14, 2005, 12:27:45 AM »

Yeah I guess I could do the timevar thing, but I'm not much of a star on timevar yet, I know what it shows off and no need to explain stuff here, i just dont know all tricks yet but ill find out how to work it from here.

Thanks for all your help people!
Logged
Kendaer
Guest
« Reply #11 on: October 14, 2005, 11:33:44 AM »

That's why I said there was no guarantee - runonce is based on the assumption that at least one player logs in each day, which is not necessarily a given.   Wink

Although I suppose he could do some date math magic to ascertain whether any amount of real days had elapsed since the last player logged in.

Well no, I was referring to the fact that you said it occured once per server new day and that was the wrong part Smiley
It is *tested* to see if it should fire every time *any* player has a new day, whether that's a server new day or the admin triggering the newday by hand, etc Smiley
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
34 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search