Hi, I have decided to make a MUD and now that I have my box on T1, I'm starting to prepare. My first question for this mailing list is: Has anyone used the AFK code from the CircleMUD snippets site (Great one, Alex!) which allows the player to leave a message when AFK? If so, you may have encountered the same bug as I. When a player goes AFK it's fine, when they come back it's fine, but if they go AFK again, BUG!!! MUD crash. I'm not great with coding, I'm just trying to get something going that my friends and I and others can enjoy. Here is the code, perhaps some of you can help me? --- BEGIN SNIPPET --- Date: Sun, 16 Feb 1997 18:17:49 -0800 (PST) From: Rasdan <thomajam@ucs.orst.edu> To: CircleMUD List <circle@cspo.queensu.ca> Subject: [Code] New AFK command Hey all, Here is my version of an AFK command. FEATURES: * Allows you to set an afk message. * Allows a message to be displayed to whoever is telling to you that you are afk, and what that message is. * Displays to the room your message when you are afk, and informs everyone in the room when you are back from AFK. Here it is: In structs.h, #define PRF_AFK (1 << ##) /* Player is AFK */ where ## is whatever is next on your PRF listing. In char_player_data, add: char *afk_message; /* PC / NPC's AFK MESSAGE */ In char_file_u, add: char afk_message[POOF_LENGTH + 1]; ------------------------ NOTE: THIS WILL CORRUPT YOUR PFILE! --------------- With the function prototypes at the top of utils.h, add: void set_afk(struct char_data *ch, char *afk_message); with the POOFIN(ch) defines, put #define GET_AFK(ch) ((ch)->player.afk_message) If you want it to save in pfile, you will need to modify the character saving/loading functions in db.c In limits.c, add: void set_afk(struct char_data * ch, char *afk_message) { if (strlen(afk_message) > POOF_LENGTH) afk_message[POOF_LENGTH] = '\0'; if (GET_AFK(ch) != NULL) free(GET_AFK(ch)); GET_AFK(ch) = str_dup(afk_message); } In act.other.c, put this: ACMD(do_afk) { long result; if (IS_NPC(ch)) return; skip_spaces(&argument); if (!*argument) { result = PRF_TOG_CHK(ch, PRF_AFK); GET_AFK(ch) = "I am AFK!"; } else { result = PRF_TOG_CHK(ch, PRF_AFK); set_afk(ch, argument); } if (result) { sprintf(buf, "%s has just gone AFK: %s\r\n", GET_NAME(ch), GET_AFK(ch)); send_to_room(buf, ch->in_room); } else { sprintf(buf, "%s is back from AFK!\r\n", GET_NAME(ch)); send_to_room(buf, ch->in_room); } return; } In act.comm.c, in ACMD(do_tell) after else if (PRF_FLAGGED(vict, PRF_NOTELL) || ROOM_FLAGGED(vict->in_room, ROOM_SOUNDPROOF)) act("$E can't hear you.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP); add: else { if (PRF_FLAGGED(vict, PRF_AFK)) { sprintf(buf, "%s is AFK and may not hear your tell.\r\n", GET_NAME(vict)); send_to_char(buf, ch); sprintf(buf, "MESSAGE: %s\r\n", GET_AFK(vict)); send_to_char(buf, ch); } In act.informative.c, in list_one_char, after: if (PLR_FLAGGED(i, PLR_WRITING)) strcat(buf, " [COMPOSING]"); <---- I think it's (Composing) in stock Circle add: if (PRF_FLAGGED(i, PRF_AFK)) strcat(buf, " [AFK]"); In do_who after if (PRF_FLAGGED(tch, PRF_NOTELL)) strcat(buf, " [NO-TELLS]"); <---- Think it is (No-Tell) in stock Circle if (PRF_FLAGGED(tch, PRF_AFK)) strcat(buf, " [AFK]"); In comm.c, in make_prompt, before: if (PRF_FLAGGED(d->character, PRF_DISPHP)) sprintf(prompt, "%s%s<%dhp ", prompt, CBBLU(d->character,C_SPR),GET_HIT(d->character)); add: if (PRF_FLAGGED(d->character, PRF_AFK)) sprintf(prompt, "%s%s[AFK]%s", prompt, CBCYN(d->character, C_SPR), CCNRM(d->character, C_SPR)); That should be it! As always, if you have any questions at all, contact me at: thomajam@ucs.orst.edu Rasdan =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= James C. Thomas Jr. --- END SNIPPET --- I'd appreciate help and I'm glad to be on the mailing list! -Tony Robbins A.K.A. Belgarath +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST