global messages

Posted by Taebryn on Sun 25 Jan 2004 03:00 AM — 10 posts, 34,868 views.

#0
i would like to code in global messages such as connect messages that are displayed all over the world

ex:
Cadwick has connected to the game.
Cadwick has disconnected from the game.

and i would like to code in an 'ooc' command or a 'narrate' command, works like the say command but chat is displayed in all rooms

ex:
OOC hello everyone
Sam (OOC): Hello everyone

any ideas? ive tried adding connect messages right after it logs it to buf, but i can never get it to work

thanks
Australia Forum Administrator #1
It already does them (eg. admins "tell to all") so to help you, you need to post what you did so we can see what is wrong with it.
USA #2
This is easy enough. This is taken from my code (I'm going to assume you have SMAUG):

find the end of the nanny function in comm.c, which should look like this (or something similar):

    act( AT_ACTION, "$n has entered the game.", ch, NULL, NULL, TO_ROOM );
    do_look( ch, "auto" );
    mail_count(ch);
    break;

    }

    return;
}

Then just make it look like this this:

    act( AT_ACTION, "$n has entered the game.", ch, NULL, NULL, TO_ROOM );
    sprintf( buf, "%s has connected to the game", ch->name );
    echo_to_all( AT_GREEN, buf, ECHOTAR_ALL );
    do_look( ch, "auto" );
    mail_count(ch);
    break;

    }

    return;
}


Then at the top of do_quit in act_comm.c, define buf. Then, go down and find the line:

act( AT_BYE, "$n has left the game.", ch, NULL, NULL, TO_ROOM );


After that line, add this:
sprintf( buf, "%s has disconnected from the game", ch->name );
echo_to_all( AT_GREEN, buf, ECHOTAR_ALL );

Of course you can change AT_GREEN to whatever color you want. As for the OOC channel or w/e, you just have to mess with your channel files and settings. Follow the steps below:

Stick this function in act_comm.c

void do_ooc( CHAR_DATA *ch, char *argument )
{
    talk_channel( ch, argument, CHANNEL_OOC, "ooc" );
    return;
}

Update tables.c to include the do_ooc function so you can use it on your mud (once this compiles, create it by doing cedit ooc create do_ooc ). You need to update the talk_channel function. Look through the function and find the line that says:
switch ( channel )

Below it should be lots of stuff. If its not in there already, just add something similar to this:

    case CHANNEL_OOC:
        set_char_color( AT_OOC, ch );
        sprintf( buf, "(OOC) $n: $t" );
        position        = ch->position;
        ch->position    = POS_STANDING;
        act( AT_OOC, buf, ch, argument, NULL, TO_CHAR );
        ch->position    = position;
        break;

Just note that that is what mine is, your can be different depending on how you want things done and whatnot. It will require tinkering. Also, one last thing, you may need to update mud.h. If so (you'll get an error about AT_OOC not exisiting), go into mud.h and search for something similar to this:
#define AT_RED 9

Just go to the last one and add:
#define AT_OOC 20

Note: 20 should be the number of the last one + 1. I'm not sure why you don't have an OOC channel with stock though.

Sorry if this was just blaber and you don't understand. All of this is in relation to my SWR 1.0 FUSS modified codebase, so yeah.

Good luck.
#3
i have tried what you said, i do get a message now when some1 leaves, it says

$n has left the game
$n has left the game

it does not fill in a name, and it says it twice
what am i doing wrong
#4
Concerning the OOC channel you want:

Open up act_comm.c and find the function do_chat. Below it, add this function:

void do_ooc( CHAR_DATA *ch, char *argument )
{
if (NOT_AUTHED(ch))
{
send_to_char("Huh?\n\r", ch);
return;
}
talk_channel( ch, argument, CHANNEL_OOC, "say OOC" );
return;
}

Then, in that same file, find void talk_command and locate the switch (channel). Add the following case:

case CHANNEL_OOC:
set_char_color( AT_GOSSIP, ch );
ch_printf( ch, "You (OOC): %s\n\r", verb, argument );
sprintf( buf, "$n (OOC): $t", verb );
break;

Now, in act_info.c, locate void do_channels and in the section of channels that everyone can see, add:

ch_printf_color( ch, "%s", !IS_SET( ch->deaf, CHANNEL_OOC ) ?
" &G+OOC" :
" &g-ooc" );

below the part for Yell. Scroll down a bit until you see a section that lists all of the channels in a format similar to this:

else if ( !str_cmp( arg+1, "ooc" ) ) bit = CHANNEL_OOC;

Add that line directly above:

else if ( !str_cmp( arg+1, "all" ) ) ClearAll = TRUE;

And then go to the next part which has lines like this:

REMOVE_BIT (ch->deaf, CHANNEL_OOC);

and add yours to the list. Do the same thing for the SET_BIT section right below it (except replace REMOVE_BIT with SET_BIT, of course.

Now, open mud.h and find the Channel Bits section. Add your new channel using the line:

#define CHANNEL_OOC BV28

If you already have a 28, use 29, etc. In the command functions area of mud.h, add:

DECLARE_DO_FUN( do_ooc );

Then, open tables.c and add:

if ( !str_cmp( name, "do_ooc" )) return do_ooc;

under the 'o' case of switch( name[3] ) of the DO_FUN *skill_function( char *name ) area.

Finally, under char *skill_name( DO_FUN *skill ) in the same tables.c file, add:

if ( skill == do_ooc ) return "do_ooc";

Now, delete tables.o, act_comm.o, and act_info.o and then make. And then startup your MUD, and type:

cedit ooc create do_ooc
cedit ooc level 1
cedit ooc flags possessed polymorphed

And that's it! It sounds harder than it is... If I could figure it out, and I know little to nothing about code, I'm sure you can get it. Hope this helps. Sorry it's so messy. :/
#5
thanks, the ooc channel works fine now

its just the enter and exit messages that dont
#6
OK, I've got up to everything but the adding of the DO_FUN in tables.c for some reason it refuses to work and gives me the error:

/home/thyrisor/public_html/dist/src/tables.c:489: undefined reference to `do_ooc'
tables.o(.text+0x5bd4): In function `skill_name':
/home/thyrisor/public_html/dist/src/tables.c:1136: undefined reference to `do_ooc'
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make[1]: Leaving directory `/home/thyrisor/thyris.org/html/dist/src'
make: *** [all] Error 2

I'm so confused :/
USA #7
Did you remember to add the line in mud.h?
USA #8
Looks like a linker error. Did you add the function do_ooc? Did you call it something else? More importantly, did you call it exactly what you entered in tables.c?

Could you perhaps provide the lines of code it is referring to?
USA #9
Regarding the entrance and exit messages, I used Rantic's info channel snippet, and it works beautifully for me, which can be found on Cronel's site at http://cronel.mube.net/code.shtml look for infochan.tgz, it's pretty nice and it announces Player logins, logouts, deaths, and level gains without modification.

For the ooc channel.. I took the easy way out and just changed the code for the traffic channel (which I couldn't see a real use for) to read the way I wanted so I'd have an OOC channel instead.. don't forget to use cedit online to create the command to actually use the new channel as well.