Indexing Duplicate Variables In An Array

hello all i have been writing a mud all year and when monsters are in the room it displays like so:

There is a dragon, a dragon, and a minotaur here.

i do this using the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void show_monsters(Player *p,int room)
{
   int i,m,p;
   int c = 0;
   int monsters[NMRMMN];

   for(i=0; i < MAX_MONSTERS; i++)
   {
      if((monster[i].active==1) && (monster[i].loc==room))
      {
         monsters[c++] = i;
      }
   }

   if(c)
   {
      sendplayer(p,BRRED,"\r\nThere is ");

      for(i=0; i < c; i++)
      {
         m = monster[monsters[i]].number
         p = monster[m].prefix;

         if((monsters[i] < MAX_MONSTERS) && 
            (monsters[(i+1)] < MAX_MONSTERS) && 
            (i<(NMRMMN-1)))
         {
            if(i == 0) sendplayer(p,BRRED," %s %s",pfx[p],monster[m].name);
            else sendplayer(p,BRRED,", %s %s",pfx[p].name,monster[m].name);
         }
         else
         {
            if(i == 0) sendplayer(p,BRRED," %s %s",pfx[p],monster[m].name);
            else sendplayer(p,BRRED,", and %s %s",pfx[p].monster[m].name);
         }
      }

      sendplayer(p,BRRED," here.");
      sendplayer(p,WHITE,"\r\n");
   }
}


now what i want to do is index em by counts, so it would instead read out:

There are two dragons, and a minotaur here.

could someone point me in the best direction to how to go about doing this?

thanks.
Topic archived. No new replies allowed.