This is what I have:
/* Generalized communication function by Fred C. Merkel (Torg). */
ACMD(do_gen_comm)
{
struct descriptor_data *i;
char color_on[24];
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH], *msg;
bool emoting = FALSE;
/* Array of flags which must _not_ be set in order for comm to be heard. */
int channels[] = {
0,
PRF_NOSHOUT,
PRF_NOGOSS,
PRF_NOAUCT,
PRF_NOGRATZ,
PRF_NOGOSS,
0
};
int hist_type[] = {
HIST_HOLLER,
HIST_SHOUT,
HIST_GOSSIP,
HIST_AUCTION,
HIST_GRATS,
};
/* com_msgs: [0] Message if you can't perform the action because of noshout
* [1] name of the action
* [2] message if you're not on the channel
* [3] a color string.
* [4] IMMORT gossip
* [5]
* [6] */
const char *com_msgs[][7] = {
{"You cannot holler!!\r\n",
"holler",
"",
KYEL,
NULL,
"hollers",
"hollers"},
{"You cannot shout!!\r\n",
"shout",
"Turn off your noshout flag first!\r\n",
KYEL,
NULL,
"shouts",
"shouts"},
{"You cannot gossip!!\r\n",
"gossip",
"You aren't even on the channel!\r\n",
KYEL,
"gossip across the world",
"gossips across the world",
"gossips across the world"},
{"You cannot auction!!\r\n",
"auction",
"You aren't even on the channel!\r\n",
KMAG,
NULL,
"auctions",
"auctions"},
{"You cannot congratulate!\r\n",
"congrat",
"You aren't even on the channel!\r\n",
KGRN,
NULL,
"congrats",
"congrats"},
{"You cannot gossip your emotions!\r\n",
"gossip",
"You aren't even on the channel!\r\n",
KYEL,
NULL,
NULL,
NULL}
};
if (PLR_FLAGGED(ch, PLR_NOSHOUT)) {
send_to_char(ch, "%s", com_msgs[subcmd][0]);
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD)) {
send_to_char(ch, "The walls seem to absorb your words.\r\n");
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SILENCE) && (GET_LEVEL(ch) < LVL_GOD)) {
send_to_char(ch, "You are in a silence zone, you can't make a sound!\r\n");
return;
}
if (SECT(ch->in_room) == SECT_UNDERWATER) {
send_to_char(ch, "Speak underwater, are you mad???\r\n");
return;
}
if (IS_AFFECTED(ch, AFF_SILENCE)) {
send_to_char(ch, "You are silenced, you can't make a sound!\r\n");
return;
}
if (subcmd == SCMD_GEMOTE) {
if (!*argument)
send_to_char(ch, "Gemote? Yes? Gemote what?\r\n");
else
do_gmote(ch, argument, 0, 1);
return;
}
/* Level_can_shout defined in config.c. */
if (GET_LEVEL(ch) < CONFIG_LEVEL_CAN_SHOUT) {
send_to_char(ch, "You must be at least level %d before you can %s.\r\n", CONFIG_LEVEL_CAN_SHOUT, com_msgs[subcmd][1]);
return;
}
/* Make sure the char is on the channel. */
if (!IS_NPC(ch) && PRF_FLAGGED(ch, channels[subcmd])) {
send_to_char(ch, "%s", com_msgs[subcmd][2]);
return;
}
/* skip leading spaces */
skip_spaces(&argument);
/* Make sure that there is something there to say! */
if (!*argument) {
send_to_char(ch, "Yes, %s, fine, %s we must, but WHAT???\r\n", com_msgs[subcmd][1], com_msgs[subcmd][1]);
return;
}
if (subcmd == SCMD_HOLLER) {
if (GET_MOVE(ch) < CONFIG_HOLLER_MOVE_COST) {
send_to_char(ch, "You're too exhausted to holler.\r\n");
return;
} else
GET_MOVE(ch) -= CONFIG_HOLLER_MOVE_COST;
}
/* Set up the color on code. */
strlcpy(color_on, com_msgs[subcmd][3], sizeof(color_on));
/* First, set up strings to be given to the communicator. */
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK);
else {
if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument))
parse_at(argument);
snprintf(buf1, sizeof(buf1), "%sYou %s: %s%s%s", COLOR_LEV(ch) >= C_CMP ? color_on : "",
(com_msgs[subcmd][4] != NULL && !IS_NPC(ch) && GET_LEVEL(ch) >= LVL_IMMORT) ? com_msgs[subcmd][4] : com_msgs[subcmd][1],
argument, COLOR_LEV(ch) >= C_CMP ? color_on : "", CCNRM(ch, C_CMP));
msg = act(buf1, FALSE, ch, 0, 0, TO_CHAR | TO_SLEEP);
add_history(ch, msg, hist_type[subcmd]);
}
if (!emoting)
snprintf(buf1, sizeof(buf1), "$n %s: %s", (com_msgs[subcmd][4] != NULL && !IS_NPC(ch) && GET_LEVEL(ch) >= LVL_IMMORT)
? com_msgs[subcmd][6] : com_msgs[subcmd][5], argument);
/* Now send all the strings out. */
for (i = descriptor_list; i; i = i->next) {
if (STATE(i) != CON_PLAYING || i == ch->desc || !i->character )
continue;
if (!IS_NPC(ch) && (PRF_FLAGGED(i->character, channels[subcmd]) || PLR_FLAGGED(i->character, PLR_WRITING)))
continue;
if (ROOM_FLAGGED(IN_ROOM(i->character), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD))
continue;
if (subcmd == SCMD_SHOUT && ((world[IN_ROOM(ch)].zone != world[IN_ROOM(i->character)].zone) ||
!AWAKE(i->character)))
continue;
snprintf(buf2, sizeof(buf2), "%s%s%s", (COLOR_LEV(i->character) >= C_NRM) ? color_on : "", buf1, KNRM);
msg = act(buf2, FALSE, ch, 0, i->character, TO_VICT | TO_SLEEP);
add_history(i->character, msg, hist_type[subcmd]);
}
}