Re: [code] [NEWBIE] Question about calling GET_CLASS(ch)

From: Rick Glover (magik@THEGRID.NET)
Date: 11/07/98

-----Original Message-----
From: Andrew <object@ALPHALINK.COM.AU>
To: <>
Date: Saturday, November 07, 1998 12:51 AM
Subject: Re:  [code] [NEWBIE] Question about calling GET_CLASS(ch)

>>do_score in act.informative.c The below is what I tried to use:
>>  sprintf(buf, "Class: %d", GET_CLASS(ch));
>>  if (GET_REMORT(ch) >= 0) {
>>  sprintf(buf,  "   Dual: %d", GET_REMORT(ch));
>> }


>/* Start code here */
> sprintf(buf + strlen(buf), "Class: ");
> switch(GET_CLASS(ch)) {
>      sprintf(buf + strlen(buf), "Magic User\r\n");
>      break;
>      sprintf(buf + strlen(buf), "Cleric\r\n");
>      break;

Actually, since class.c contains a nice constant called pc_class_types[],
you can use that to convert the decimal to string.  The include at the top
of act.informative.c gives you the external declaration that you need for
it, so just:

Change your:
  sprintf(buf, "Class: %d", GET_CLASS(ch));
  sprintf(buf, "Class: %s\r\n", pc_class_types[(int)GET_CLASS(ch)]);
  send_to_char(buf, ch);


P.S. I added the \r\n so you'd go down to another line and send_to_char() so
that you can see it.  :)

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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