Who command update [by Nashak]
Snippet Posted Wednesday, August 12th @ 11:38:56 PM, by George Greer in the Commands dept.
Added Dec 3, 1996. Click the link below to read it or download it.

From: Brian Williams <bmw@efn.org>
Subject: New who

ACMD(do_who)
{
  struct descriptor_data *d;
  struct char_data *wch;
  char godbuf[MAX_STRING_LENGTH];
  char mortbuf[MAX_STRING_LENGTH];
  char name_search[MAX_NAME_LENGTH+1];
  char mode;

  int low = 0, high = LVL_IMPL, showclass = 0;
  bool who_room = FALSE, who_zone = FALSE, who_quest = 0;
  bool outlaws = FALSE, noimm = FALSE, nomort = FALSE;

  int gods = 0, morts = 0;
  size_t i;

  const char *godlevs[LVL_IMPL - (LVL_IMMORT-1)] = {
    "    &02Demi God&00   ",
    "   &05Lesser God&00  ",
    "  &04Greater God&00  ",
    "     &12Forger&00    "
  };


  skip_spaces(&argument);
  strcpy(buf, argument);
  name_search[0] = '\0';

  while (*buf) {
    half_chop(buf, arg, buf1);
    if (isdigit(*arg)) {
      sscanf(arg, "%d-%d", &low, &high);
      strcpy(buf, buf1);
    } else if (*arg == '-') {
      mode = *(arg + 1);
/* just in case; we destroy arg in the switch */
      switch (mode) {
      case 'o':

outlaws = TRUE;

strcpy(buf, buf1);

break;
      case 'z':

who_zone = TRUE;

strcpy(buf, buf1);

break;
      case 'q':

who_quest = TRUE;

strcpy(buf, buf1);

break;
      case 'l':

half_chop(buf1, arg, buf);

sscanf(arg, "%d-%d", &low, &high);

break;
      case 'n':

half_chop(buf1, name_search, buf);

break;
      case 'r':

who_room = TRUE;

strcpy(buf, buf1);

break;
      case 'c':

half_chop(buf1, arg, buf);

for (i = 0; i < strlen(arg); i++)

  showclass |= find_class_bitvector(arg[i]);

break;
      case 'i':
        nomort = TRUE;
        strcpy(buf, buf1);
        break;
      case 'm':
        noimm = TRUE;
        strcpy(buf, buf1);
        break;
      default:

send_to_char(WHO_USAGE, ch);

return;

break;
      }



/* end of switch */

    } else {


/* endif */
      send_to_char(WHO_USAGE, ch);
      return;
    }
  }



/* end while (parser) */

  strcpy(godbuf, " &04Listing of the Gods\r\n&06-=-=-=-=-=-=-=-=-=-=-&00\r\n");
  strcpy(mortbuf," &04List of the Mortals\r\n&06-=-=-=-=-=-=-=-=-=-=-&00\r\n");

  for (d = descriptor_list; d; d = d->next) {
    if (d->connected)
      continue;

    if (d->original)
      wch = d->original;
    else if (!(wch = d->character))
      continue;

    if (!CAN_SEE(ch, wch))
      continue;
    if (GET_LEVEL(wch) < low || GET_LEVEL(wch) > high)
      continue;
    if ((noimm && GET_LEVEL(wch) >= LVL_IMMORT) || (nomort && GET_LEVEL(wch) <
LVL_IMMORT))
      continue;
    if (*name_search && str_cmp(GET_NAME(wch), name_search) && !strstr(GET_TITL
E(wch), name_search))
      continue;
    if (outlaws && !PLR_FLAGGED(wch, PLR_KILLER) && !PLR_FLAGGED(wch, PLR_THIEF
))
      continue;
    if (who_quest && !PRF_FLAGGED(wch, PRF_QUEST))
      continue;
    if (who_zone && world[ch->in_room].zone != world[wch->in_room].zone)
      continue;
    if (who_room && (wch->in_room != ch->in_room))
      continue;
    if (showclass && !(showclass & (1 << GET_CLASS(wch))))
      continue;

  if (!PRF_FLAGGED(wch, PRF_ANON)) {
    if (GET_LEVEL(wch) >= LVL_IMMORT) {
      sprintf(godbuf, "%s[%s] %s %s", godbuf,
              godlevs[GET_LEVEL(wch)-LVL_IMMORT], GET_NAME(wch),
              GET_TITLE(wch));
      gods++;
    } else {
      sprintf(mortbuf, "%s[%2d %s] %s %s (%s)", mortbuf, GET_LEVEL(wch),

      CLASS_ABBR(wch), GET_NAME(wch), GET_TITLE(wch), RACE_ABBR(wch));
      morts++;
    }
  } else {
    if (GET_LEVEL(wch) >= LVL_IMMORT) {
      sprintf(godbuf, "%s[ &16- Anonymous -&00 ] %s %s", godbuf, GET_NAME(wch),
              GET_TITLE(wch));
      gods++;
    } else {
      sprintf(mortbuf, "%s[ &16- Anonymous -&00 ] %s %s (%s)", mortbuf, GET_NAM
E(wch),
              GET_TITLE(wch), RACE_ABBR(wch));
      morts++;
    }
  }

    *buf = '\0';
    if (GET_INVIS_LEV(wch))
      sprintf(buf, "%s (i%d)", buf, GET_INVIS_LEV(wch));
    else if (IS_AFFECTED(wch, AFF_INVISIBLE))
      strcat(buf, " (invis)");

    if (PLR_FLAGGED(wch, PLR_MAILING))
      strcat(buf, " (mailing)");
    else if (PLR_FLAGGED(wch, PLR_WRITING))
      strcat(buf, " (writing)");

    if (PRF_FLAGGED(wch, PRF_DEAF))
      strcat(buf, " (deaf)");
    if (PRF_FLAGGED(wch, PRF_NOTELL))
      strcat(buf, " (notell)");
    if (PRF_FLAGGED(wch, PRF_QUEST))
      strcat(buf, " (quest)");
    if (PLR_FLAGGED(wch, PLR_THIEF))
      strcat(buf, " (THIEF)");
    if (PLR_FLAGGED(wch, PLR_KILLER))
      strcat(buf, " (KILLER)");
    if (PRF_FLAGGED(wch, PRF_AFK))
      strcat(buf, " (&09AFK&00)");
    strcat(buf, "\r\n");

    if (GET_LEVEL(wch) >= LVL_IMMORT)
      strcat(godbuf, buf);
    else
      strcat(mortbuf, buf);

  }



/* end of for */

  if (gods == 0)
    sprintf(godbuf, "%s<none>\r\n", godbuf);

    sprintf(godbuf, "%s\r\n&13There %s &00%d&13 visible immortal%s.&00\r\n", go
dbuf, (gods == 1 ? "is" : "are"), gods, (gods == 1 ? "" : "s"));
    page_string(ch->desc, godbuf, 0);
    send_to_char("\r\n", ch);

  if (morts == 0)
    sprintf(mortbuf, "%s<none>\r\n", mortbuf);

    sprintf(mortbuf, "%s\r\n&13There %s &00%d&13 visible mortal%s.&00", mortbuf
, (morts == 1 ? "is" : "are"), morts, (morts == 1 ? "" : "s"));
    page_string(ch->desc, mortbuf, 0);
    send_to_char("\r\n", ch);

  strcat(buf, "\r\n");

  if ((gods + morts) > boot_high)
    boot_high = gods+morts;
  sprintf(buf, "%s&06Total visible players: &04%d&00.\r\n", buf, gods+morts);
  sprintf(buf, "%s&13Maximum number of players on this boot: &00&04%d&00.\r\n",
 buf, boot_high);
  send_to_char(buf, ch);
}


<< Water Currents [by Chuck Reed] | Reply | View as text | Threaded | who -> html for web pages [by Erik Niese-Petersen] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.