[CODE] Newbie Snippet --- Loads a "bug" (obj #0, or #1)

From: Julian Buckley (s348266@STUDENT.UQ.EDU.AU)
Date: 02/27/98


I have a slight problem with the newbie code --- when I do it, it loads
the eq's correctly, but it also loads a bug!  I've got a feeling the
problem is in the code:

 for(ii = 1; give_obj[ii] != -1; ii++) {

but I dont know.  The full snippet follows:
What am I doing wrong?
***This is not my code --- trying to alter a error in code snippet***

ACMD(do_newbie)
{
   struct char_data *victim;
   struct obj_data *obj;
   int ii, tmp;

        /* My objs...insert yours here */
   int give_obj[] = { 3009, 3010, -1 };

   one_argument(argument, buf);

   if(IS_NPC(ch)) {
      send_to_char("Monsters can't help newbies!\n\r", ch);
      return;
   }
   if (!*buf)
      send_to_char("Who would you like to newbie?\n\r", ch);
   else if (str_cmp("all", buf)) {
      if (!(victim = get_char_vis(ch, buf)))
          send_to_char("You cant find that person!\n\r", ch);
      else if (victim == ch)
          send_to_char("You're just a LITTLE to high to be newbied!\n\r",
ch);
      else {
       if (GET_LEVEL(victim) > 5) {
          send_to_char("That victim is too experienced to newbie!\n\r",
ch);
          return;
       }
       for(ii = 1; give_obj[ii] != -1; ii++) {
          obj = read_object(give_obj[ii], VIRTUAL);
            if (obj == NULL)
              continue;
          obj_to_char(obj, victim);
       }
       switch (GET_CLASS(victim)) {
       case CLASS_THIEF:
         tmp = 0;
         break;
       case CLASS_WARRIOR:
         tmp = 1;
         break;
       }
       obj = read_object(tmp, VIRTUAL);
       if (obj == NULL)
         return;
       obj_to_char(obj, victim);
       send_to_char("Done.\n\r", ch);
         sprintf(buf, "(GC) %s just newbie-equipped %s.", GET_NAME(ch),
         GET_NAME(victim));
         mudlog(buf, CMP, LVL_IMMORT, TRUE);
      }
      send_to_char("You have been equipped by the gods!\n\r", victim);
    }
}




-----------------------------------------------------------------
 Julian Buckley, 2nd Year Computer Systems Engineering
 Dept. Computer Science and Electrical Engineering, Univ. of Qld
 E-Mail: s348266@student.uq.edu.au
 Web Page: http://student.uq.edu.au/~s348266/index.html
-----------------------------------------------------------------


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



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