/* The notify command allows players to place other players on a notify * list, whether the victim is online or not. When the victim logs on, or * logs off, all players with victim's name on their notify list receive * a message stating that fact. * Syntax: * notify - lists players currently on notify list * notify none - erases all names currently on list * notify <player> - adds player to list if not there already - * if there, it removes player from list * * Notify command written by Sadiq - 02/06/99 * Refer questions/comments to: sadiq@a-znet.com * * Permission to use and distribute this code is given, provided that: * 1). A help file exists in the mud where it is used, with the * notify command as it's subject. * 2). I am credited in the notify help file as the author. * 3). All headers and comments must remain intact */ INSTALLATION: In mud.h: ========= Find the list of structure types, and add this to the bottom: typedef struct notify_data NOTIFY_DATA; Find the part where colors are defined, and add this: #define AT_NOTIFY AT_WHITE /* Make this whatever color fits your mud. */ Find the part that defines the ignore structure, and MAX_IGNORE. Under that add: /* Structure for a linked list of players on notify - Sadiq */ struct notify_data { NOTIFY_DATA *next; NOTIFY_DATA *prev; char * name; }; /* Max number of people you can have on notify at once - Sadiq */ #define MAX_NOTIFY 10 /* Set this to whatever wish to allow. Remember that pfiles fill up fast! */ Then add this to pc_data struct: NOTIFY_DATA * first_notify; /* used to keep track of persons on notify - Sadiq */ NOTIFY_DATA * last_notify; Next, right after: DECLARE_DO_FUN( do_notell ); Add this: DECLARE_DO_FUN( do_notify ); Finally, near the bottom of the file, add this to the bottom of the section where the functions for act_info.c are declared: bool on_notify args( ( CHAR_DATA *ch, CHAR_DATA *victim ) ); In act_comm.c: ============== in do_quit, right after: sprintf( log_buf, "%s has quit (Room %d).", ch->name, ( ch->in_room ? ch->in_room->vnum : -1 ) ); add this: for ( d = first_descriptor; d; d = d->next ) { CHAR_DATA *vch; NOTIFY_DATA *temp; temp = NULL; vch = d->character; if ( d->connected == CON_PLAYING && vch != ch) { for(temp = vch->pcdata->first_notify; temp; temp = temp->next) { if (on_notify(vch, ch) == TRUE && temp->name == ch->name ) { set_char_color(AT_NOTIFY,vch); ch_printf(vch,"NOTIFICATION: %s has left the game.\n\r",temp->name); break; } } } } In act_info.c: ============== Drop all of this into the bottom of the file: /* * Notify command written by Sadiq - 02/06/99 */ void do_notify(CHAR_DATA *ch, char *argument) { char arg[MAX_INPUT_LENGTH]; NOTIFY_DATA *temp, *next; char fname[1024]; struct stat fst; CHAR_DATA *victim; if(IS_NPC(ch)) return; argument = one_argument(argument, arg); sprintf(fname, "%s%c/%s", PLAYER_DIR, tolower(arg[0]), capitalize(arg)); victim = NULL; /* If no arguments, then list players currently on notify list */ if(arg[0] == '\0') { set_char_color(AT_DIVIDER, ch); ch_printf(ch, "\n\r----------------------------------------\n\r"); set_char_color(AT_WHITE, ch); ch_printf(ch, "Players you currently have on notify:\n\r"); set_char_color(AT_DIVIDER, ch); ch_printf(ch, "----------------------------------------\n\r"); set_char_color(AT_NOTIFY, ch); if(!ch->pcdata->first_notify) { ch_printf(ch, "\t no one\n\r"); return; } for(temp = ch->pcdata->first_notify; temp; temp = temp->next) { ch_printf(ch,"\t - %s\n\r",temp->name); } return; } /* Clear players on notify if given arg "none" */ else if(!strcmp(arg, "none")) { for(temp = ch->pcdata->first_notify; temp; temp = next) { next = temp->next; UNLINK(temp, ch->pcdata->first_notify, ch->pcdata->last_notify, next, prev); STRFREE(temp->name); DISPOSE(temp); } set_char_color(AT_NOTIFY, ch); ch_printf(ch, "You now are not being notified about anyone.\n\r"); return; } /* Prevent someone from placing themselves on notify. */ else if(!strcmp(arg, "self") || nifty_is_name(arg, ch->name)) { set_char_color(AT_NOTIFY, ch); ch_printf(ch, "Now that would be kind of....err...well....stupid, wouldn't it?\n\r"); return; } else { int i; /* Loop through the linked list of players on the notify */ /* list, and keep track of how many are on the list */ for(temp = ch->pcdata->first_notify, i = 0; temp; temp = temp->next, i++) { /* If the argument matches a name in list remove it */ if(!strcmp(temp->name, capitalize(arg))) { UNLINK(temp, ch->pcdata->first_notify, ch->pcdata->last_notify, next, prev); set_char_color(AT_NOTIFY, ch); ch_printf(ch,"You no longer have %s on notify.\n\r", temp->name); STRFREE(temp->name); DISPOSE(temp); return; } } /* Allow players to add other players that are not logged */ /* on, or who have no pfiles yet. (But are connected) */ if( stat(fname, &fst) == -1 && (!(victim = get_char_world(ch, arg)) || IS_NPC(victim) || strcmp(capitalize(arg),victim->name) != 0)) { set_char_color(AT_NOTIFY, ch); ch_printf(ch,"No player exists by that" " name.\n\r"); return; } if(victim) { strcpy(capitalize(arg),victim->name); } /* If its valid and the list size limit has not been */ /* reached, create a node and add it to the list */ if(i < MAX_NOTIFY) { NOTIFY_DATA *new; CREATE(new, NOTIFY_DATA, 1); new->name = STRALLOC(capitalize(arg)); new->next = NULL; new->prev = NULL; LINK(new, ch->pcdata->first_notify, ch->pcdata->last_notify, next, prev); set_char_color(AT_NOTIFY, ch); ch_printf(ch,"You now have %s on notify.\n\r", new->name); return; } else { set_char_color(AT_NOTIFY, ch); ch_printf(ch,"You may only have %d players on notify.\n\r", MAX_NOTIFY); return; } } } /* * Simple bool that checks to see if ch has victim on notify. */ bool on_notify(CHAR_DATA *ch, CHAR_DATA *victim) { NOTIFY_DATA *temp; if(IS_NPC(ch) || IS_NPC(victim)) return FALSE; for(temp = ch->pcdata->first_notify; temp; temp = temp->next) { if(nifty_is_name(temp->name, victim->name)) return TRUE; } return FALSE; } In comm.c: ========== in nanny, near the end of the function, right after this: if ( get_timer( ch, TIMER_PKILLED ) > 0 ) remove_timer( ch, TIMER_PKILLED ); add this: for ( d = first_descriptor; d; d = d->next ) { CHAR_DATA *vch; NOTIFY_DATA *temp; temp = NULL; vch = d->character; if ( d->connected == CON_PLAYING && vch != ch) { for(temp = vch->pcdata->first_notify; temp; temp = temp->next) { if (on_notify(vch, ch) == TRUE && temp->name == ch->name ) { set_char_color(AT_NOTIFY,vch); ch_printf(vch,"NOTIFICATION: %s has entered the game.\n\r",temp->name); break; } } } } In db.c: ======== in free_char(), right after this: stop_hunting( ch ); stop_hating ( ch ); stop_fearing( ch ); free_fight ( ch ); if ( ch->pnote ) free_note( ch->pnote ); add this: if ( ch->pcdata ) { NOTIFY_DATA *temp, *next; /* free up memory allocated to store notify names */ for(temp = ch->pcdata->first_notify; temp; temp = next) { next = temp->next; UNLINK(temp, ch->pcdata->first_notify, ch->pcdata->last_notify, next, prev); STRFREE(temp->name); DISPOSE(temp); } } In save.c: ========== in fwrite_char(), right after this: IGNORE_DATA *temp; for(temp = ch->pcdata->first_ignored; temp; temp = temp->next) { fprintf(fp,"Ignored %s~\n", temp->name); } } add this: /* If there are names on the notify list, write them to pfile */ { NOTIFY_DATA *temp; for(temp = ch->pcdata->first_notify; temp; temp = temp->next) { fprintf(fp,"Notify %s~\n", temp->name); } } in load_char_obj(), right after this: ch->morph = NULL; add this: ch->pcdata->first_notify = NULL; /* Notify list */ ch->pcdata->last_notify = NULL; in fread_char(), look for : case 'N': right after that, and BEFORE this: KEY ("Name", ch->name, fread_string( fp ) ); add this: if(!strcmp(word, "Notify")) { char *temp; char fname[1024]; struct stat fst; int noti; NOTIFY_DATA *nnode; /* Get the name */ temp = fread_string(fp); sprintf(fname, "%s%c/%s", PLAYER_DIR, tolower(temp[0]), capitalize(temp)); /* If there isn't a pfile for the name */ /* then don't add it to the list */ if(stat(fname, &fst) == -1) { fMatch = TRUE; break; } /* Count the number of names on notify list. */ for(noti = 0, nnode = ch->pcdata->first_notify; nnode; nnode = nnode->next) { noti++; } /* Add the name unless the limit has been reached */ if(noti >= MAX_NOTIFY) { bug("fread_char: too many notify names"); } else { /* Add the name to the list */ CREATE(nnode, NOTIFY_DATA, 1); nnode->name = STRALLOC(temp); nnode->next = NULL; nnode->prev = NULL; LINK(nnode, ch->pcdata->first_notify, ch->pcdata->last_notify, next, prev); } fMatch = TRUE; break; } Make clean and recompile. Note that this command may be expanded (To notify of deaths, for example) fairly easily. The meat of the whole thing (as far as expanding the code) is this: for ( d = first_descriptor; d; d = d->next ) { CHAR_DATA *vch; NOTIFY_DATA *temp; temp = NULL; vch = d->character; if ( d->connected == CON_PLAYING && vch != ch) { for(temp = vch->pcdata->first_notify; temp; temp = temp->next) { if (on_notify(vch, ch) == TRUE && temp->name == ch->name ) { set_char_color(AT_NOTIFY,vch); ch_printf(vch,"NOTIFICATION: %s <your message here>.\n\r",temp->name); break; } } } } Just put that bit of code into whatever function you want to allow players to be notified of, and change the message that's sent to the player. Suggested help file (cut and paste this directly into help.are, in the appropriate spot): 1 NOTIFY~ . &R********************************************************************** &GSyntax: &Cnotify &GSyntax: &Cnotify <character> &GSyntax: &Cnotify none &R********************************************************************** &WThe notify command allows you to make a short list of players. Then, whenever one of those players log on or off the game, you recieve a notification stating that fact. &GNOTIFY &Wwill display a list of those on your list. &GNOTIFY NONE &Wwill erase EVERY name from your list. &GNOTIFY &C<player> &Wif the player is on your list, it will remove them. if not on your list, it will add them. Your notify list can not hold more than 10 names. The notify code was written by Sadiq. &R********************************************************************** &w ~