/* add this to act_info.c, * this gives the players an option * to, when they go afk, put a message * that can be retrieved on a finger :). * idea taken from Last Rites lr2.com 9000 * add this line to your includes :) */ * * version 1.1 * fixes a couple bugs: * mud crased on fingering a mob * mud crashed on fingering yourself * also something about crashing when your afk with a message * but its all bug free so i think :) * * version 1.2 * fixed the last remaining bug (hopefully) * was in do_afk * * verision 1.3 * fixed the very last bug :), wasn't closing fpReserve *doh* * email me at chancedj@peaknet.net if you find any bugs */ #include add afk_msg to the char_data struct in merc.h void do_finger(CHAR_DATA *ch, char *argument) { char *word; CHAR_DATA *victim; FILE *fp; char arg[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH]; int level; struct stat statbuf; bool fingerimms; buf[0] = '\0'; buf2[0] = '\0'; one_argument(argument, arg); /* set to true if you want morts fingering imms */ fingerimms = FALSE; if (arg[0] == '\0') { send_to_char("Syntax: finger \n\r", ch ); return; } strcpy(arg,capitalize(arg)); sprintf(buf, "%s%s", PLAYER_DIR, arg); if ((victim = get_char_world(ch,arg)) == NULL) { /* found that it didn't like it if i left this opened :) */ fclose(fpReserve); if ((fp = fopen(buf,"r")) == NULL) { sprintf( buf, "%s not found.\n\r", capitalize(arg)); send_to_char(buf, ch); return; } for( ; ; ) { word = feof( fp ) ? "NotFound" : fread_word( fp ); if( !str_cmp( word, "Level" ) || !str_cmp( word, "Lev" ) || !str_cmp( word, "Levl" ) ) { level = fread_number( fp ); break; } else if( !str_cmp( word, "NotFound" ) ) { level = -1; break; } } fclose( fp ); fpReserve = fopen( NULL_FILE, "r" ); if ( level < 0 ) { send_to_char("Freaky pfile, note imms about it!\n\r", ch); return; } if (get_trust(ch) < level && level >= LEVEL_IMMORTAL && !fingerimms) { send_to_char("Tsk. Tsk. No fingering your superiors!\n\r", ch ); return; } stat(buf,&statbuf); sprintf(buf, "%s was last online %s\n\r", arg, ctime( &statbuf.st_mtime )); send_to_char(buf, ch); return; } else { if (IS_NPC(victim)) { send_to_char("Yeah, mobs around somewhere.\n\r", ch ); return; } if (ch == victim) { send_to_char("Yes, you are online.\n\r", ch); return; } if (IS_IMMORTAL(victim) && (get_trust(ch) < victim->level) && !fingerimms) { send_to_char("Tsk. Tsk. No fingering your superiors!\n\r", ch ); return; } if (IS_SET(victim->comm, COMM_AFK)) sprintf(buf2, "\n\rAFK MSG: %s\n\r", victim->afk_msg); sprintf(buf, "%s has been idle for %d ticks%s", victim->name,victim->timer, buf2[0] == '\0' ? "\n\r" : buf2); send_to_char(buf, ch); return; } } /* new afk, if yours is differnt, just add the commented lines. */ void do_afk(CHAR_DATA *ch, char *argument) { if (IS_SET(ch->comm,COMM_AFK)) { send_to_char("AFK mode removed. ", ch ); /* this change makes it so that it only gives you * the "reply to see tells" if you have any waiting */ if (buf_string(ch->pcdata->buffer)[0] != '\0') send_to_char("Type 'replay' to see tells.", ch ); send_to_char("\n\r",ch); // ch->afk_msg = NULL; REMOVE_BIT(ch->comm,COMM_AFK); } else { // /* slight bug here, fixed, thanks Blade :) */ // if (argument[0] != '\0') // ch->afk_msg = str_dup( argument ); // else // ch->afk_msg = "None"; send_to_char("You are now in AFK mode.\n\r",ch); SET_BIT(ch->comm,COMM_AFK); } }