Liblist Commands: Rlist, Mlist, Olist Commands [by Myrddin]
Snippet Posted Wednesday, August 12th @ 11:29:53 PM, by George Greer in the Wizard dept.
. Click the link below to read it or download it.

                         RLIST, MLIST, OLIST COMMANDS

These commands should server to list rooms, mobiles and objects on
your mud in the range given.

ACMD(do_rlist)
{
  extern struct room_data *world;
  extern int top_of_world;

  int first, last, nr, found = 0;

  two_arguments(argument, buf, buf2);

  if (!*buf || !*buf2) {
    send_to_char("Usage: rlist  \r\n", ch);
    return;
  }

  first = atoi(buf);
  last = atoi(buf2);

  if ((first < 0) || (first > 99999) || (last < 0) || (last > 99999)) {
    send_to_char("Values must be between 0 and 99999.\n\r", ch);
    return;
  }

  if (first >= last) {
   send_to_char("Second value must be greater than first.\n\r", ch);
    return;
  }

  for (nr = 0; nr <= top_of_world && (world[nr].number <= last); nr++) {
    if (world[nr].number >= first) {
      sprintf(buf, "%5d. [%5d] (%3d) %s\r\n", ++found,
              world[nr].number, world[nr].zone,
              world[nr].name);
      send_to_char(buf, ch);
    }
  }

  if (!found)
    send_to_char("No rooms were found in those parameters.\n\r", ch);
}


ACMD(do_mlist)
{
  extern struct index_data *mob_index;
  extern struct char_data *mob_proto;
  extern int top_of_mobt;

  int first, last, nr, found = 0;
  two_arguments(argument, buf, buf2);

  if (!*buf || !*buf2) {
    send_to_char("Usage: mlist  \r\n", ch);
    return;
  }

  first = atoi(buf);
  last = atoi(buf2);

  if ((first < 0) || (first > 99999) || (last < 0) || (last > 99999)) {
    send_to_char("Values must be between 0 and 99999.\n\r", ch);
    return;
  }

  if (first >= last) {
    send_to_char("Second value must be greater than first.\n\r", ch);
    return;
  }

  for (nr = 0; nr <= top_of_mobt && (mob_index[nr].virtual <= last); nr++) {
    if (mob_index[nr].virtual >= first) {
      sprintf(buf, "%5d. [%5d] %s\r\n", ++found,
              mob_index[nr].virtual,
              mob_proto[nr].player.short_descr);
      send_to_char(buf, ch);
    }
  }

  if (!found)
    send_to_char("No mobiles were found in those parameters.\n\r", ch);
}


ACMD(do_olist)
{
  extern struct index_data *obj_index;
  extern struct obj_data *obj_proto;
  extern int top_of_objt;

  int first, last, nr, found = 0;

  two_arguments(argument, buf, buf2);

  if (!*buf || !*buf2) {
    send_to_char("Usage: olist  \r\n", ch);
    return;
  }
  first = atoi(buf);
  last = atoi(buf2);

  if ((first < 0) || (first > 99999) || (last < 0) || (last > 99999)) {
    send_to_char("Values must be between 0 and 99999.\n\r", ch);
    return;
  }

  if (first >= last) {
    send_to_char("Second value must be greater than first.\n\r", ch);
    return;
  }

  for (nr = 0; nr <= top_of_objt && (obj_index[nr].virtual <= last); nr++) {
    if (obj_index[nr].virtual >= first) {
      sprintf(buf, "%5d. [%5d] %s\r\n", ++found,
              obj_index[nr].virtual,
              obj_proto[nr].short_description);
      send_to_char(buf, ch);
    }
  }

  if (!found)
    send_to_char("No objects were found in those parameters.\n\r", ch);
}


<< Language Addition [by Frollo] | Reply | View as text | Threaded | Liblist: Room/Object/Mob listing [by Stormrider] >>

 


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.
 
 


liblists
by Gad (gad@unbounded.com) on Thursday, March 2nd @ 08:31:48 PM
http://
Hi, i tried to use your snippet, but it doesn't seem to work for me. I think it is because i am using a different patch level. Can you convert that so it is compatible with patch level 17? if someone could do this for me it would be great. i'm still dumb so i can't figure it out myself. it's with the obj_index[nr].virtual. it keeps saying .virtual aint a member of that structure. can ya tell me what does go there?

P.S. i tried .number too, but it just crashed the mud every time i use it.
[ Reply to this comment ]

Re: liblists
by Bob (Superbob@hotmail.com) on Wednesday, March 8th @ 07:42:12 PM
http://
Try .vnum instead of .virtual there, rusty.
Its not that tough.
[ Reply to this comment ]

Re: liblists
by Aldur (aldur_the_small@hotmail.com) on Wednesday, May 30th @ 10:49:46 AM
http://
Also change
extern int top_of_objt;
extern int top_of_mobt;

by
extern obj_rnum top_of_objt;
extern mob_rnum top_of_mobt;

or it'll give you some troubles and bugs
[ Reply to this comment ]