Re: [CODE]Glist

From: Daniel Koepke (dkoepke@california.com)
Date: 01/26/97


On Sun, 26 Jan 1997, Daniel Durnin wrote:

> Can anyone send me the code for a "glist" command that shows the current groups?
> Been trying to figure this out from Diku samples, to no avail.

Go through the list of character's and find the group leaders.  Then
you just list their followers who have AFF_GROUP set on them.

  ACMD(do_glist) {
    struct char_data *tch;
    struct follow_type *f;
    int col = 1;

    for (tch = character_list; tch; tch = tch->next) {
      // this might be a nasty assuption: a group leader is someone
      // without a master and is affected by AFF_GROUP; I'm not sure
      // if 'master' is set when someone groups themselves, so you
      // might need to change this
      if (!tch->master && IS_AFFECTED(tch, AFF_GROUP)) {
        sprintf(buf, "Group leader: %s\r\n", GET_NAME(tch));
        send_to_char(buf, ch);

        for (f = tch->followers; f; f = f->next) {
          if (!IS_AFFECTED(f->follower, AFF_GROUP))
            continue;
          sprintf(buf, "%-15s ", GET_NAME(f->follower));
          if (!((col++) % 3) strcat(buf, "\r\n");
          send_to_char(buf, ch);
        }
        if (col % 3) send_to_char("\r\n", ch);
        send_to_char("\r\n");
      }
    }
  }

Written in my mailer, completely untested, use at your own risk.  You
may or may not need to change it, I'm not very famliliar with how Circle
handles grouping, especially what happens when the group leaders groups
himself (would ch->master then be set to ch?).  Anyway, good luck.
Tell me if you can get it to work, if you can't, uh, you can tell me
that, although I don't know whether or not I'll be any help.
       
*Waiting and hoping to see the Packers lose*


--
Daniel Koepke
dkoepke@california.com
Forgive me father, for I am sin.


+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST