> I would like to know if someone knows how to make the mud reboot at a > specific time, for example, you set it to reboot in 1 days and 3 hours(in > real time), and let it tick down from that.. if anyone have any idea, help > me :) > Hi... Well one way was to use the time(0) to retrieve current time value and then add on the period you want to in seconds. Somthing like this (this only fast guide) Keep in mind I havn't tested this.. Could give it an argument saying, shutdown timed days hours minutes *** START CODE *** /* goto config.c */ *** add this somewhere in the bottom ** int reboot_state = 0; /* this assumes you save and reload the time_boot variable else set it = 0*/ time_t time_boot; /* put this into the shutdown function in act.wizard.c with the changes that are needed */ /** in the top add **/ extern time_t time_boot; time_t time_now; char days_p[MAX_INPUT_LENGTH], hours_p[MAX_INPUT_LENGTH], minutes_p[MAX_INPUT_LENGTH], boot_method[MAX_INPUT_LENGTH], junk[MAX_INPUT_LENGTH]; char *timestr; int days = 0, hours = 0, minutes = 0; half_chop(argument, junk, argument); half_chop(argument, boot_method, argument); half_chop(argument, days_p, argument); half_chop(argument, hours_p, argument); half_chop(argument, minutes_p, reason); if (!strcmp(boot_method, "timed") ) { if(!isdigit(*days_p) || !isdigit(*hours_p) || !isdigit(*minutes_p)) { send_to_char("Please give time values in digits Usage Example: shutdown timed 1 5 0\r\n"); return; } days = atoi(days_p); hours = atoi(hours_p); minutes = atoi(minutes_p); /* Get current time */ time_now = time(0); /* Get the time for the boot into time_boot */ time_boot = time_now + (86400 * days); /* add the days */ time_boot += hours * 3600; /* add the hours */ time_boot += minutes *60; /* add the minutes */ /* set the reboot_state */ reboot_state = 1; /* Show the time of boot */ timestr = (char *) asctime(localtime(&time_boot)); *(timestr + strlen(tmstr) - 1) = '\0'; /* this for bpl before sprintf got integrated with send_to_char, was it 21?*/ sprintf(buf, "(GC) Timed shutdown set by %s Mud will reboot on: %s\r\n", GET_NAME(ch), timestr); mudlog(buf, BRF, LVL_IMMORT, TRUE); sprintf(buf, "/007/007*** Mud will reboot on: %s\r\n ***", timestr); send_to_all(buf); /* if you want to preserve the boot time over a chrash, I suggest you save time_boot and reboot_state in a file and load it on boots */ } **** now we move to comm.c *** *** add somewhere in the top where you feel it belong ** extern int time_boot; extern int reboot_state; ** this in the heartbeat function for instance below zone_update(); ** if (!(pulse % (PASSES_PER_SEC))) { /* Timed Reboot */ if (reboot_state) { reboot_time = time_boot - time(0); if (reboot_time == 3600) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 60 minutes.\r\n"); if (reboot_time == 1800) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 30 minutes.\r\n"); if (reboot_time == 600) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 10 minutes.\r\n"); if (reboot_time == 300) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 5 minutes.\r\n"); if (reboot_time == 240) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 4 minutes.\r\n"); if (reboot_time == 180) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 3 minutes.\r\n"); if (reboot_time == 120) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 2 minutes.\r\n"); if (reboot_time == 60) send_to_all("\007\007[**WARNING**] YOURMUDNAME is rebooting in 1 minute.\r\n"); if (reboot_time <= 0) { send_to_all("Rebooting.. come back in a minute or two.\r\n"); touch(FASTBOOT_FILE); circle_shutdown = circle_reboot = 1; } else { reboot_time--; } } } *** STOP CODE *** I might have forgotten something, but the basics should be there. Mail me for questions. Christian -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT