Re: [CODE][LONG] Training Snippet

From: Thomas Arp (t_arp@mail1.stofanet.dk)
Date: 04/22/00


I reformatted the spec_proc a bit for better readability. Everything I tried to dublicate the error
failed. Actually I downloaded the snippet and just after that, everything worked like a charm.


SPECIAL(trainer)
{
  if (IS_NPC(ch) || !CMD_IS("train"))
    return 0;

  one_argument(argument, arg);

  if (!*arg)
    {
[snip]
      sprintf(buf + strlen(buf),"You have %d training session%s.\r\n",
        GET_TRAINING(ch), (GET_TRAINING(ch) == 1) ? "" : "s");

      send_to_char(buf,ch);
      return 1;
    }

  if (GET_TRAINING(ch) <= 0)
    {
      send_to_char("You do not seem to be able to train now.\r\n", ch);
      return 1;
    }

  if (!strcmp(arg,"hit"))
    {
      GET_TRAINING(ch) -=1;
      GET_MAX_HIT(ch) +=5;
    }
  else if (!strcmp(arg,"mana"))
// instead of:  else if (strcmp(arg, "mana")==0)  - they both work, though.
    {
[snip]
    }
  else
    {
      send_to_char("Train what?\r\n",ch);
      sprintf(buf, "The arg was: %s\r\n", arg);
      send_to_char(buf, ch);
      return 1;
    }
  send_to_char("You train for a while...\r\n",ch);
  return 1;
}

Whatley wrote:
> And if you have trains all it does is go directly to the invalid arg statement,
> if you have no trains it give you the GET_TRAINS <= 0  message.

It doesn't make much sense to me, that the proc should go to the invalid arg
statement, unless you've got an extra { to match the } before the else.
If I were you I'd check my brackets.

Welcor


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT