Channel History v1.0 by Coelbren of WinterMUD
		Coelbren Ar Beirdd
                coelbren@tds.net

I saw the History snippet by Rashin posted on Kyndig, and I liked the idea.
The problem was, I wanted to use the snippet for more then one channel, and
I didn't want to add arguments to do_history, so.. I came up with this 
solution: all the channels have a check for the 'history' argument. So
typing in:

:<20hp 20m 20mv> gossip history

would show the last 8 Gossips from the MUD. 


I dont ask for any credit for this snippet, I dont even want an email,
this snippet is way to small to require anything like that. If you want
to shoot me an email, thats fine, but w/e.

Usually around here I would tell you to email me with any bugs/fixes.
But... this snippet is so small, I cant imagine any bugs, and this
will probably the the last (and only) release. If I come up with a 
better way to do this, I will post that as a snippet, and If you come
up with a better way to do this, let me know.





<--Start Snippet-->

Ok, at the top of act_comm.c, we need to add some strings to hold the
history of the channels. You need to make X amount of strings for
EVERY channel you want the history feature enabled for. So, if I 
wanted say, Gossip and Immtalk to have history, I would add this to
the top of act_comm.c

char* gossip1;
char* gossip2;
char* gossip3;
char* gossip4;
char* gossip5;
char* gossip6;
char* gossip7;
char* gossip8;

char * immtalk1, immtalk2, immtalk3, immtalk4, immtalk5, immtalk6, immtalk7, immtalk8;

/* There is no difference between gossipX and immtalkX, its just syntax, use whichever you like */








Ok, now (still in act_comm.c), in the function for w/e channel(s)
this is being installed for, we need to add a few lines towards the
bottom: (lines with a + infront are lines you should add, lines w/o
the + are already in act_comm.c) This needs to be repeated for every
channel (e.g. do_gossip, do_music, do_clantalk)


        for (d = descriptor_list; d != NULL; d = d->next)
        {
            CHAR_DATA *victim;

            victim = d->original ? d->original : d->character;

            if (d->connected == CON_PLAYING &&
                d->character != ch &&
                !IS_SET (victim->comm, COMM_NOGOSSIP) &&
                !IS_SET (victim->comm, COMM_QUIET))
            {
                act_new ("{d$n gossips '{D$t{d'{x",
                         ch, argument, d->character, TO_VICT, POS_SLEEPING);
            }
        }

+    	sprintf (buf, "{d%s Gossiped '{D%s{d'{x\n\r", ch->name, argument);
+        addfree_string(music8);        
+        gossip8 = gossip7;
+        gossip7 = gossip6;
+        gossip6 = gossip5;
+        gossip5 = gossip4;
+        gossip4 = gossip3;
+        gossip3 = gossip2;
+        gossip2 = gossip1;
+        gossip1 = str_dup(buf);

    }
} /* this is the closing bracket of do_whatever */



Ok, now, back towards the top of the channel's function, we need to add a check, to see
if the history argument was passed. Same syntax as before, and again this needs to be done
in every channel's respective function:


        if (IS_SET (ch->comm, COMM_NOGOSSIP))
        {
            send_to_char ("Gossip channel is now ON.\n\r", ch);
            REMOVE_BIT (ch->comm, COMM_NOGOSSIP);
        }
        else
        {
            send_to_char ("Gossip channel is now OFF.\n\r", ch);
            SET_BIT (ch->comm, COMM_NOGOSSIP);
        }
    }

+    else if ( !str_cmp(argument, "history") )
+    {
+
+       send_to_char ("{b.{C======================[{W Last 8 Gossips {C]======================{b.{x\n\r", ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip8);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip7);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip6);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip5);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip4);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip3);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip2);
+       send_to_char (buf, ch);
+       sprintf (buf, "{B.{W %s{x\n\r", gossip1);
+       send_to_char (buf, ch);
+       send_to_char ("{b.{C============================================================={b.{x\n\r", ch);
+       return;
+    }

    else
    {                            /* gossip message sent, turn gossip on if it isn't already */

        if (IS_SET (ch->comm, COMM_QUIET))
        {
            send_to_char ("You must turn off quiet mode first.\n\r", ch);
            return;
        }









And thats it. I'm running this code right now with no problems. There is only one thing
I can think of that might be considered a bug. If there aren't any (or < 8) recent
messages on the channel, it shows up as:

.===[Last 8 Musics]===.
-(null)
-(null)
-(null)
-(null)
-(null)
.=====================.


I dont see this as a problem,  but if you dont like it you can add some code
to the IF check, so that if A) All strings are empty, it tells the character its all
empty, B) if any of the strings are empty, its just says nothing. Here is the code for that
so that any new coders dont have to go post on mudmagic.com that they cant figure it out:


    else if ( !str_cmp(argument, "history") )
    {
       if( gossip1[0] == '\0'){
           send_to_char(ch, "No history recorded.");
           return;
        }

       send_to_char ("{b.{C======================[{W Last 8 Gossips {C]======================{b.{x\n\r", ch);


       if( gossip8[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip8);
       send_to_char (buf, ch); }
       if( gossip7[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip7);
       send_to_char (buf, ch);}
       if( gossip6[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip6);
       send_to_char (buf, ch); }
       if( gossip5[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip5);
       send_to_char (buf, ch); }
       if( gossip4[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip4);
       send_to_char (buf, ch); }
       if( gossip3[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip3);
       send_to_char (buf, ch); }
       if( gossip2[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip2);
       send_to_char (buf, ch); }
       if( gossip1[0] = '\0' ){
           send_to_char(ch, "{B.{W...{x\n\r"); }   
       else{
       sprintf (buf, "{B.{W %s{x\n\r", gossip1);
       send_to_char (buf, ch); }


       send_to_char ("{b.{C============================================================={b.{x\n\r", ch);
       return;
    }





Hope you like the snippet. It took me maybe 5 min. to write up, its nothing to advanced hehe.


+/                                              \+
+| Check out WinterMUD: wintermud.noip.com 7000 |+
+\                                              /+