From: dennis@starlifter.reichel.net

Due to numerous bugs/problems with the info channel code I posted
recently, and demand for a *working* version of it, here's a version that
includes features such as not showing the message to a certain character
(Yeah.. I know I just logged on.  Why am I getting an info telling me that?),
and restricting the message to a certain level or over (one way to keep
from broadcasting imms logging on to mortals, while still telling imms)

I haven't installed this code in a mud, but it does make it through
compilation on this machine without fussing.

If you don't care about this, know of a much better, easier, cleaner way
of doing the same thing, don't like me personally, or just plain don't
want to continue, you can quit reading now. The rest of this post is just
the code and installation instructions.

==========================================================================

void info( CHAR_DATA * ch, int level, char * message, ...)
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA * d;
    va_list args;

    va_start(args,message);
    vsnprintf(buf, MAX_STRING_LENGTH, message, args);
    va_end(args);

    for ( d = descriptor_list; d; d = d->next )
    {
        if ( d->connected == CON_PLAYING && 
             d->character != ch &&
             get_trust(d->character) >= level )
           send_to_char(buf, d->character);
    }
}

void do_info(CHAR_DATA * ch, char * argument)
{
    if (IS_SET(ch->comm,COMM_NOINFO))
    {
        send_to_char("Info channel is now ON.\n\r",ch);
        REMOVE_BIT(ch->comm,COMM_NOINFO);
    }
    else
    {
        send_to_char("Info channel is now OFF.\n\r",ch);
        SET_BIT(ch->comm,COMM_NOINFO);
    }
}

=================================================================

Installation
============
1. Put the above code in act_comm.c

2. One thing I left off in the original post: You need to add

     #include <stdarg.h>

   at the top of the file, with the other #includes.

3. You'll need to add COMM_NOINFO to the list of COMM_ flags in merc.h

4. You'll need to add do_info to interp.h and interp.c

5. You'll need to add the declaration for info in merc.h

      void info(CHAR_DATA * ch, int level, char * message, ...);

6. Recompile and pray it works.


Use
===
To broadcast a message to everyone currently on the mud that has info
channel turned on (this could be useful):

   info( NULL , 0 , "Dennis Rocks!" );

To broadcast a message to everyone who has info channel on except a
certain character (most used version):

   info( ch, 0, "%s just logged on!", ch->name );

To broadcast a message to all imms with info channel on except a certain
character (useful for imms logging on):

   info( ch, LEVEL_IMMORTAL, "%s just logged on!", ch->name );

To have a function call that accomplishes absolutely no useful purpose:

   info( ch, MAX_LEVEL + 1, "Boo!" );

I think you get the point...


I haven't completely tested this, so I don't promise anything about it.
Use at your own risk.  If you find any bugs, e-mail me.

Dennis

/************************************************************************\
*   Dennis Reed   *   dreed@usa.net   *   http://www.dreed.home.ml.org   *
\************************************************************************/
 \              Coder on Triad - triad.telmaron.com 7777                /
  **********************************************************************
