Private Channel code by Darksword (Leon Vignes) [Cities of Glory (COG): bucket.ualr.edu 4000] To check out the code in action just drop by COG and try it out. This code allows players to create private channels similar to group channels, but the players do not have to be grouped. The channels are based on the idnum of the player who opens the channel. Players cannot join a channel but must be added to it by the player who opens it. The player who opens the channel can add/remove players or close the channel at will. If you like this code please just drop me an email at sword@bucket.ualr.edu so I know wether or not I should post code like this in the future. PS I know the code isn't hard and isn't anything great but I figured someone might use it :). The following files will need to be modified. structs.h 1 line interpreter.h 9 lines utils.h 1 line act.comm.c interpreter.c act.wizard.c 4 lines or so -- optional The lines you need to modify are marked by --> except the do_private_channel function which all needs to go in. I think thats it. Here goes... Step #1 Add private channel variable to the player structure, this variable does not need to be saved. struct player_special_data { struct player_special_data_saved saved; char *poofin; /* Description on arrival of a god. */ char *poofout; /* Description upon a god's exit. */ struct alias *aliases; /* Character's aliases */ long last_tell; /* idnum of last tell from */ void *last_olc_targ; /* olc control */ int last_olc_mode; /* olc control */ ... --> int private; /* Private channel */ Step #2 Add the following defines to interpreter.h /* do_gen_com */ #define SCMD_HOLLER 0 #define SCMD_SHOUT 1 #define SCMD_GOSSIP 2 #define SCMD_AUCTION 3 #define SCMD_GRATZ 4 ... --> #define SCMD_PRIVATE X --> /* do_private_channel */ --> #define PRIVATE_HELP 0 --> #define PRIVATE_OPEN 1 --> #define PRIVATE_CLOSE 2 --> #define PRIVATE_OFF 3 --> #define PRIVATE_ADD 4 --> #define PRIVATE_REMOVE 5 --> #define PRIVATE_WHO 6 --> #define PRIVATE_CHECK 7 Step #3 Add to utils.h --> #define GET_PRIVATE(ch) ((ch)->player_specials->private) Step #4 Add the following line to the ACMD defines in interpreter.c --> ACMD(do_private_channel); then add these commands to the command parser list in interpreter.c private = psay = . you can change or remove any of these. --> { "private" , POS_DEAD , do_gen_comm , 0, SCMD_PRIVATE }, --> { "psay" , POS_DEAD , do_gen_comm , 0, SCMD_PRIVATE }, --> { "." , POS_DEAD , do_gen_comm , 0, SCMD_PRIVATE }, --> { "padd" , POS_DEAD , do_private_channel , 0, PRIVATE_ADD }, --> { "pclose" , POS_DEAD , do_private_channel , 0, PRIVATE_CLOSE }, --> { "phelp" , POS_DEAD , do_private_channel , 0, PRIVATE_HELP }, --> { "poff" , POS_DEAD , do_private_channel , 0, PRIVATE_OFF }, --> { "popen" , POS_DEAD , do_private_channel , 0, PRIVATE_OPEN }, --> { "premove" , POS_DEAD , do_private_channel , 0, PRIVATE_REMOVE }, --> { "pwho" , POS_DEAD , do_private_channel , 0, PRIVATE_WHO }, --> { "pcheck" , POS_DEAD , do_private_channel,LVL_IMPL, PRIVATE_CHECK } , Step #5 ADD do_private_channel function to file act.comm.c (just to keep it with the player communication functions) NOTE The help and all functions needed were kept in one function in order to make adding in the code as quick as possible. /* ******************************************************************** ACMD(do_private_channel) { struct char_data *vict; struct descriptor_data *i; half_chop(argument, buf, buf2); if (subcmd == PRIVATE_HELP) { send_to_char("Private Channel (PC) commands\r\n", ch); send_to_char("------------------------\r\n", ch); send_to_char("popen - opens your own private channel.\r\n", ch); send_to_char("padd - adds a player to your PC.\r\n", ch); send_to_char("premove - remove a player from your PC.\r\n", ch); send_to_char("pclose - closes your private channel.\r\n", ch); send_to_char("pwho - lists all members on the current PC.\r\n", ch); send_to_char("poff - exits you from your current PC.\r\n\r\n", ch); send_to_char(" NOTE: If you don't want to be added to another\r\n", ch); send_to_char(" player's PC open your own with no players.\r\n", ch); send_to_char("\r\nTo talk on the channel use -- private, psay or .\r\n",ch); } else if (subcmd == PRIVATE_OPEN) { GET_PRIVATE(ch) = GET_IDNUM(ch); send_to_char("You have just opened your own Private Channel.\r\n", ch); } else if (subcmd == PRIVATE_OFF) { GET_PRIVATE(ch) = 0; send_to_char("You have just quit any Private Channels.\r\n", ch); } else if (subcmd == PRIVATE_CLOSE) { GET_PRIVATE(ch) = 0; /* now remove all people on the private channel */ for (i = descriptor_list; i; i = i->next) if (!i->connected) if ((GET_PRIVATE(i->character) == GET_IDNUM(ch)) && (ch != i->character)) { GET_PRIVATE(i->character) = 0; sprintf(buf, "%s has just closed their Private Channel.\r\n", GET_NAME(ch)); send_to_char(buf, i->character); } send_to_char("You have just CLOSED your Private Channel.\r\n", ch); } else if (subcmd == PRIVATE_WHO) { if (GET_PRIVATE(ch) == 0) send_to_char("You are not on a private channel\r\n",ch); else { /* show all people on the private channel */ send_to_char("Private Channel Members\r\n", ch); send_to_char("-----------------------\r\n", ch); for (i = descriptor_list; i; i = i->next) if (!i->connected) if (GET_PRIVATE(i->character) == GET_PRIVATE(ch)) { sprintf(buf, "%s\r\n", GET_NAME(i->character)); send_to_char(buf, ch); } } } else if (subcmd == PRIVATE_CHECK) { /* show all people on the ALL private channels */ send_to_char("Private Channels\r\n", ch); send_to_char("---------------------------------------------\r\n", ch); for (i = descriptor_list; i; i = i->next) if (!i->connected) { sprintf(buf, "[%-5d] %s\r\n", GET_PRIVATE(i->character), GET_NAME(i->character)); send_to_char(buf, ch); } } else if (subcmd == PRIVATE_REMOVE) { if (!*buf) send_to_char("Who do you wish to add to you private channel?\r\n", ch); else if (!(vict = get_char_vis(ch, buf))) send_to_char(NOPERSON, ch); else if (IS_NPC(vict)) send_to_char("NPC's cannot be on private channels\r\n", ch); else if (GET_PRIVATE(vict) != GET_IDNUM(ch)) { sprintf(buf,"%s is NOT on your Private Channel!\r\n", GET_NAME(vict)); send_to_char(buf, ch); } else { GET_PRIVATE(vict) = 0; sprintf(buf,"You have been REMOVED from %s's Private Channel!\r\n", GET_NAME(ch)); send_to_char(buf, vict); sprintf(buf,"%s has been REMOVED from your Private Channel!\r\n", GET_NAME(vict)); send_to_char(buf, ch); } } else if (subcmd == PRIVATE_ADD) { if (GET_PRIVATE(ch) != GET_IDNUM(ch)) send_to_char("You must open your own private channel first\r\n",ch); else if (!*buf) send_to_char("Who do you wish to add to you private channel?\r\n", ch); else if (!(vict = get_char_vis(ch, buf))) send_to_char(NOPERSON, ch); else if (ch == vict) GET_PRIVATE(ch) = GET_IDNUM(ch); else if (IS_NPC(vict)) send_to_char("NPC's cannot be added to private channels\r\n", ch); else if (GET_PRIVATE(vict) != 0) { sprintf(buf,"%s is already on another private channel!\r\n", GET_NAME(vict)); send_to_char(buf, ch); } else { GET_PRIVATE(vict) = GET_IDNUM(ch); sprintf(buf,"You have been ADDED to %s's Private Channel!\r\n", GET_NAME(ch)); send_to_char(buf, vict); sprintf(buf,"%s has been ADDED to your Private Channel!\r\n", GET_NAME(vict)); send_to_char(buf, ch); } } } ******************************************************************** */ Step #6 Add the checks to the do_gen_comm function in act.comm.c /********************************************************************** * generalized communication func, originally by Fred C. Merkel (Torg) * *********************************************************************/ ACMD(do_gen_comm) { extern int level_can_shout; extern int holler_move_cost; struct descriptor_data *i; char color_on[24]; /* Array of flags which must _not_ be set in order for comm to be heard */ static int channels[] = { 0, PRF_DEAF, PRF_NOGOSS, PRF_NOAUCT, PRF_NOGRATZ, ... 0 }; /* * 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. */ static char *com_msgs[][4] = { {"You cannot holler!!\r\n", "holler", "", KYEL}, {"You cannot shout!!\r\n", "shout", "Turn off your noshout flag first!\r\n", KYEL}, {"You cannot gossip!!\r\n", "gossip", "You aren't even on the channel!\r\n", KYEL}, {"You cannot auction!!\r\n", "auction", "You aren't even on the channel!\r\n", KMAG}, {"You cannot congratulate!\r\n", "congrat", "You aren't even on the channel!\r\n", KGRN}, /* ***************************************************************** -- Note you could add a toggle here for private channels but I did not do it myself. I just let players open their own blank channel so they can't be added by bothersome players. PRF_NOPRIVATE - this is added above with PRF_NOGRATZ etc and must be defined {"You cannot talk on the Private Channel!\r\n", "private-say", "You aren't even on the channel!\r\n", KYEL} ***************************************************************** */ }; ... --> if (subcmd == SCMD_PRIVATE && GET_PRIVATE(ch) == 0) { --> send_to_char("You are not on a private channel!", ch); --> return; --> } /* to keep pets, etc from being ordered to shout */ if (!ch->desc) return; ... /* now send all the strings out */ for (i = descriptor_list; i; i = i->next) { if (!i->connected && i != ch->desc && i->character && (!PRF_FLAGGED(i->character, channels[subcmd]) ... --> if (subcmd == SCMD_PRIVATE && --> (GET_PRIVATE(ch) != GET_PRIVATE(i->character))) --> continue; if (subcmd == SCMD_SHOUT && ((world[ch->in_room].zone != world[i->character->in_room].zone) || GET_POS(i->character) < POS_RESTING)) continue; ... The following can be added to act.wizard.c if you want immortals/imps to be able to join channels at will. ACMD(do_set) --> { "private", LVL_IMPL, PC, NUMBER }, --> case XXXX: --> GET_PRIVATE(vict) = RANGE(0, 32000); --> break; If you have any problems or questions, drop by COG or email me. Darksword Leon Vignes