notes posted messages. This code allows for when a new message is posted alert anyone who is playing who should see this note/idea/change whatever that it was posted. in NOTE.C find void parse_note( CHAR_DATA *ch, char *argument, int type ) { BUFFER *buffer; it will be near the bottom ussually......remove this whole function and replace with the one below. /******************************************************************************* * _ | File Name: note posted message.txt * / \ _-' | Description: Displays a message to the people who * _/| \-''- _ / | are in the world when they get a new * __-' | \ | message. * / \ | * / "o. |o | | * | \ ; | * ', | * \_ __\ | (c) 2000-2001 TAKA * ''-_ \.// | (c) 2000-2001 The GhostMud Project Team * / '-____' | * / | You may use this code under GNU license restriction * _' The Wolf | 1) This header block remains in the code. * _-' strikes! | 2) You email me at a_ghost_dancer@excite.com *_________________________| letting me know you are using this code * please incluse your name, your mud name * All rights reserved your mud address, your email and this file * GhostMud is copyrighted name. * by TAKA 3) In your help files mention me where appropriate * IE: help snippets. *********************************************************************************/ void parse_note( CHAR_DATA *ch, char *argument, int type ) { BUFFER *buffer; char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; NOTE_DATA *pnote; NOTE_DATA **list; char *list_name; long vnum; long anum; DESCRIPTOR_DATA *d; if ( IS_NPC(ch) ) return; switch(type) { default: return; case NOTE_NOTE: list = ¬e_list; list_name = "notes"; break; case NOTE_IDEA: list = &idea_list; list_name = "ideas"; break; case NOTE_PENALTY: list = &penalty_list; list_name = "penalties"; break; case NOTE_NEWS: list = &news_list; list_name = "news"; break; case NOTE_CHANGES: list = &changes_list; list_name = "changes"; break; } argument = one_argument( argument, arg ); smash_tilde( argument ); if ( arg[0] == '\0' || !str_prefix( arg, "read" ) ) { bool fAll; if ( !str_cmp( argument, "all" ) ) { fAll = TRUE; anum = 0; } else if ( argument[0] == '\0' || !str_prefix(argument, "next")) /* read next unread note */ { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next) { if (!hide_note(ch,pnote)) { sprintf( buf, "{M[{G%3ld{M] {W%s{G: %s{x\n\r%s\n\r{GTo: {W%s{x\n\r", vnum, pnote->sender, pnote->subject, pnote->date, pnote->to_list); send_to_char( buf, ch ); page_to_char( pnote->text, ch ); update_read(ch,pnote); return; } else if (is_note_to(ch,pnote)) vnum++; } sprintf(buf,"{YYou have no unread %s.{x\n\r",list_name); send_to_char(buf,ch); return; } else if ( is_number( argument ) ) { fAll = FALSE; anum = atoi( argument ); } else { send_to_char( "{RRead which number?{x\n\r", ch ); return; } vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && ( vnum++ == anum || fAll ) ) { sprintf( buf, "{M[{G%3ld{M] {W%s{G: %s{x\n\r%s\n\r{GTo: {W%s{x\n\r", vnum - 1, pnote->sender, pnote->subject, pnote->date, pnote->to_list ); send_to_char( buf, ch ); page_to_char( pnote->text, ch ); update_read(ch,pnote); return; } } sprintf(buf,"{YThere aren't that many %s.{x\n\r",list_name); send_to_char(buf,ch); return; } if ( !str_prefix( arg, "list" ) ) { vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) ) { sprintf( buf, "{M[{G%3ld{D%s{M] {W%s{G: %s{x\n\r", vnum, hide_note(ch,pnote) ? " " : "N", pnote->sender, pnote->subject ); send_to_char( buf, ch ); vnum++; } } if (!vnum) { switch(type) { case NOTE_NOTE: send_to_char("{YThere are no notes for you.{x\n\r",ch); break; case NOTE_IDEA: send_to_char("{YThere are no ideas for you.{x\n\r",ch); break; case NOTE_PENALTY: send_to_char("{YThere are no penalties for you.{x\n\r",ch); break; case NOTE_NEWS: send_to_char("{YThere is no news for you.{x\n\r",ch); break; case NOTE_CHANGES: send_to_char("{YThere are no changes for you.{x\n\r",ch); break; } } return; } if ( !str_prefix( arg, "remove" ) ) { if ( !is_number( argument ) ) { send_to_char( "{RNote remove which number?{x\n\r", ch ); return; } anum = atoi( argument ); vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && vnum++ == anum ) { note_remove( ch, pnote, FALSE ); send_to_char( "{YNote removed.{x\n\r", ch ); return; } } sprintf(buf,"{YThere aren't that many %s.{x",list_name); send_to_char(buf,ch); return; } if ( !str_prefix( arg, "delete" ) && get_trust(ch) >= MAX_LEVEL - 1) { if ( !is_number( argument ) ) { send_to_char( "{RNote delete which number?{x\n\r", ch ); return; } anum = atoi( argument ); vnum = 0; for ( pnote = *list; pnote != NULL; pnote = pnote->next ) { if ( is_note_to( ch, pnote ) && vnum++ == anum ) { note_remove( ch, pnote,TRUE ); send_to_char( "{YNote deleted.{x\n\r", ch ); return; } } sprintf(buf,"{YThere aren't that many %s.{x",list_name); send_to_char(buf,ch); return; } if (!str_prefix(arg,"catchup")) { switch(type) { case NOTE_NOTE: ch->pcdata->last_note = current_time; break; case NOTE_IDEA: ch->pcdata->last_idea = current_time; break; case NOTE_PENALTY: ch->pcdata->last_penalty = current_time; break; case NOTE_NEWS: ch->pcdata->last_news = current_time; break; case NOTE_CHANGES: ch->pcdata->last_changes = current_time; break; } send_to_char("{YYou are now caught up on all your notes.{x\n\r", ch); return; } /* below this point only certain people can edit notes */ if ((type == NOTE_NEWS && !IS_TRUSTED(ch,ANGEL)) || (type == NOTE_CHANGES && !IS_TRUSTED(ch,CREATOR))) { sprintf(buf,"{RYou aren't high enough level to write %s.{x",list_name); send_to_char(buf,ch); return; } if ( !str_cmp( arg, "+" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{Y\n\r",ch); return; } if (strlen(ch->pnote->text)+strlen(argument) >= 4096) { send_to_char( "{RNote too long.{x\n\r", ch ); return; } buffer = new_buf(); add_buf(buffer,ch->pnote->text); add_buf(buffer,argument); add_buf(buffer,"\n\r"); free_string( ch->pnote->text ); ch->pnote->text = str_dup( buf_string(buffer) ); free_buf(buffer); send_to_char( "{YLine added.{x\n\r", ch ); return; } if (!str_cmp(arg,"-")) { int len; bool found = FALSE; note_attach(ch,type); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } if (ch->pnote->text == NULL || ch->pnote->text[0] == '\0') { send_to_char("{RNo lines left to remove.{x\n\r",ch); return; } strcpy(buf,ch->pnote->text); for (len = strlen(buf); len > 0; len--) { if (buf[len] == '\r') { if (!found) /* back it up */ { if (len > 0) len--; found = TRUE; } else /* found the second one */ { buf[len + 1] = '\0'; free_string(ch->pnote->text); ch->pnote->text = str_dup(buf); return; } } } buf[0] = '\0'; free_string(ch->pnote->text); ch->pnote->text = str_dup(buf); send_to_char("{YLine removed.{x\n\r", ch); return; } if ( !str_prefix( arg, "subject" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } free_string( ch->pnote->subject ); ch->pnote->subject = str_dup( argument ); send_to_char( "{YSubject added.{x\n\r", ch ); return; } if ( !str_prefix( arg, "to" ) ) { note_attach( ch,type ); if (ch->pnote->type != type) { send_to_char( "{RYou already have a different note in progress.{x\n\r",ch); return; } free_string( ch->pnote->to_list ); ch->pnote->to_list = str_dup( argument ); send_to_char( "{YNames to added.{x\n\r", ch ); return; } if ( !str_prefix( arg, "clear" ) ) { if ( ch->pnote != NULL ) { free_note(ch->pnote); ch->pnote = NULL; } send_to_char( "{YNote cleared.{x\n\r", ch ); return; } if ( !str_prefix( arg, "show" ) ) { if ( ch->pnote == NULL ) { send_to_char( "{RYou have no note in progress.{x\n\r", ch ); return; } if (ch->pnote->type != type) { send_to_char("{RYou aren't working on that kind of note.{x\n\r",ch); return; } sprintf( buf, "{W%s{G: %s\n\rTo: {W%s{x\n\r", ch->pnote->sender, ch->pnote->subject, ch->pnote->to_list ); send_to_char( buf, ch ); send_to_char( ch->pnote->text, ch ); return; } if ( !str_prefix( arg, "post" ) || !str_prefix(arg, "send")) { char *strtime; if ( ch->pnote == NULL ) { send_to_char( "{RYou have no note in progress.{x\n\r", ch ); return; } if (ch->pnote->type != type) { send_to_char("{RYou aren't working on that kind of note.{x\n\r",ch); return; } if (!str_cmp(ch->pnote->to_list,"")) { send_to_char( "{RYou need to provide a recipient (name, all, imm or immortal).{x\n\r", ch); return; } if (!str_cmp(ch->pnote->subject,"")) { send_to_char("{RYou need to provide a subject.{x\n\r",ch); return; } for(d = descriptor_list; d != NULL; d = d->next) { if(d->connected == CON_PLAYING) { if(is_name(d->character->name, ch->pnote->to_list)) { switch(ch->pnote->type) { case NOTE_NOTE: send_to_char("{YYou have a PRIVATE note.{x", d->character); break; case NOTE_IDEA: send_to_char("{YThere is an idea waiting for your eyes only.{x", d->character); break; case NOTE_PENALTY: send_to_char("{YYou have a new penalty to read.{x", d->character); break; case NOTE_NEWS: send_to_char("{YThere is a news paper at your door.{x", d->character); break; case NOTE_CHANGES: send_to_char("{YSome changes you might have interest in.{x", d->character); break; default: send_to_char("{YYou have a PRIVATE new message.{x", d->character); break; } } if(is_name("all", ch->pnote->to_list) || (d->character->level >= LEVEL_IMMORTAL && is_name("imm", ch->pnote->to_list)) || (d->character->level >= LEVEL_IMMORTAL && is_name("immortal", ch->pnote->to_list))) { switch(ch->pnote->type) { case NOTE_NOTE: send_to_char("{YYou have a new note to read.{x", d->character); break; case NOTE_IDEA: send_to_char("{YThere is an idea to read.{x", d->character); break; case NOTE_PENALTY: send_to_char("{YA new penalty awaits execution.{x", d->character); break; case NOTE_NEWS: send_to_char("{YEXTRA EXTRA read all about it! {wGhost {Ynews.{x", d->character); break; case NOTE_CHANGES: send_to_char("{YAs the wolrd turns read our newest changes.{x", d->character); break; default: send_to_char("{YYou have a new message.{x", d->character); break; } } } } ch->pnote->next = NULL; strtime = ctime( ¤t_time ); strtime[strlen(strtime)-1] = '\0'; ch->pnote->date = str_dup( strtime ); ch->pnote->date_stamp = current_time; append_note(ch->pnote); ch->pnote = NULL; return; } send_to_char( "{RYou can't do that.{x\n\r", ch ); return; }