Welcome to the Builder Academy

Question Mud Events to happen on certain days IRL.

More
08 Jul 2016 00:57 #6089 by Liko
Hello,
So I am wondering using the time procedures in C, if I can make one that would check the day and if it was to a certain day is defined something special will happen.

IE
December 25, 2016
The procedure would check to see if that day is today and if it is then x2 experience.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
08 Jul 2016 15:37 #6093 by thomas
Something like this?
Code:
int it_is_christmas() { time_t t = time(NULL); struct tm tm = *localtime(&t); if (tm.tm_mon == 11 && tm.tm_mday == 25) { return TRUE; } return FALSE; }

Now you can check in gain_exp() ( github.com/tbamud/tbamud/blob/master/src/limits.c#L235 ) whether it is happy hour:
Code:
if (gain > 0) { if ((IS_HAPPYHOUR) && (IS_HAPPYEXP)) gain += (int)((float)gain * ((float)HAPPY_EXP / (float)(100))); gain = MIN(CONFIG_MAX_EXP_GAIN, gain); /* put a cap on the max gain per kill */ + if (it_is_christmas()) { + gain *= 2; + }

Please Log in or Create an account to join the conversation.

More
09 Jul 2016 04:23 #6094 by Liko

thomas wrote: Something like this?

Code:
int it_is_christmas() { time_t t = time(NULL); struct tm tm = *localtime(&t); if (tm.tm_mon == 11 && tm.tm_mday == 25) { return TRUE; } return FALSE; }

Now you can check in gain_exp() ( github.com/tbamud/tbamud/blob/master/src/limits.c#L235 ) whether it is happy hour:
Code:
if (gain > 0) { if ((IS_HAPPYHOUR) && (IS_HAPPYEXP)) gain += (int)((float)gain * ((float)HAPPY_EXP / (float)(100))); gain = MIN(CONFIG_MAX_EXP_GAIN, gain); /* put a cap on the max gain per kill */ + if (it_is_christmas()) { + gain *= 2; + }


Ha. I was calling it wrong. I had tm.mon = DECEMBER. Silly me. I wasn't sure how to call months and days! Thanks

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

Time to create page: 0.201 seconds