Loading an item into a player's inventory by name or vnum raymond@brokersys.com This is pretty straight forward. Just call LOAD No will load it into your own inventory. You can request items by vnum or by name; dot-notation is supported; i.e. 3.sword will load the proper sword from the object prototype array. In the interests of game balance, this feature is heavily logged. There are also safeguards built in so that an item that is supposed to be !Take will not be loaded into a player's inventory unless that player is an Imp. Weight restrictions NB: load_to_recipient() was designed to be used with several creation spells to prevent idiot players from loading a million breads into their own inventory and then dropping them in a temple so new comers get spammed out of the game (I've seen this done). This function does weight and item number checks to prevent just that. /********************************************************************* Usage: Load [vnum|name] Load an item into your inventory if no target is named. If there's a target, load item into her inventory only if sh can carry the extra weight and if the item itself is not !Take. Parameters: VNUM of object or NAME (ie. Verminator or 3.sword) Target player's name ************************************************************************/ extern struct obj_data *obj_proto; void load_to_recipient (struct char_data *ch, struct char_data *recipient, struct obj_data *obj) { char tooheavy=0; char toomany=0; if ((IS_CARRYING_W(recipient) + GET_OBJ_WEIGHT(obj)) > CAN_CARRY_W(recipient)) tooheavy=1; if (IS_CARRYING_N(recipient) + 1 > CAN_CARRY_N(recipient)) toomany=1; /*allow Imp to oload !Take items for own use*/ if ((tooheavy || toomany || (!(CAN_WEAR(obj, ITEM_WEAR_TAKE)))) && (GET_LEVEL(ch) < LVL_IMPL)) { sprintf(buf2, "(GC) Oload: obj #%i by %s into %s\'s inventory", GET_OBJ_VNUM(obj), GET_NAME(ch), GET_NAME(recipient)); if ((tooheavy) || (toomany)) { sprintf(buf2+strlen(buf2), " (too heavy/many)."); send_to_char ("That item was too heavy or one to many items for your target.\r\n",ch); } else { sprintf(buf2+strlen(buf2), " (!TAKE)."); send_to_char ("That item is !TAKE.\r\n",ch); } send_to_char ("Do NOT fool around with this command; it is always logged.\r\n",ch); } else { sprintf(buf2, "(GC) Oload: obj #%i loaded by %s into %s\'s inventory.", GET_OBJ_VNUM(obj), GET_NAME(ch), GET_NAME(recipient)); obj_to_char (obj,recipient); sprintf(buf, "You place %s in %s\'s inventory.\r\n", obj->short_description, GET_NAME(recipient)); send_to_char(buf, ch); sprintf(buf, "*poof* The %s appears in your inventory.\r\n",obj->short_description); send_to_char (buf,recipient); } mudlog(buf2, NRM, LVL_IMPL, TRUE); } /* * Oload vnum * If no recipient, load obj VNUM into user's inventory. * If recipient specificed and in game, load item into his inventory. * If recipient cannot carry weight of item, it is aborted. */ ACMD(do_oload) { int number, r_num; struct obj_data *obj; struct char_data* recipient; char rec_buf[100]; char *k; char name[50]; char found_by_name=0; unsigned int temp=0, i=0; two_arguments(argument, buf, rec_buf); if(!*buf) { send_to_char("You need to give me a VNUM or NAME.\r\n", ch); return; } /*If 2.sword is Oloaded, these lines separate 2 (temp) from sword (buf)*/ k=strchr(buf,'.'); if (k) { for (i=0; i0) continue; else { number = GET_OBJ_VNUM(&obj[i]); found_by_name=1; break; } } /*loading by object name*/ } /*if !isdigit(buf)*/ if (!found_by_name) { if ((number = atoi(buf)) < 0) { send_to_char("A NEGATIVE number??\r\n", ch); return; } } if (((r_num = real_object(number)) < 0) || (number==0)) { send_to_char("There is no object with that name or number.\r\n", ch); sprintf(buf,"(GC) Oload: %s tried to load a non-existent object (%d).", GET_NAME(ch), number); mudlog(buf, NRM, LVL_IMPL, TRUE); return; } if (!*rec_buf) /*no target for load*/ { obj = read_object(r_num, REAL); sprintf(buf2, "(GC) Oload: obj #%i (%s) oloaded by %s", GET_OBJ_VNUM(obj), obj->short_description, GET_NAME(ch)); mudlog(buf2, NRM, LVL_IMPL, TRUE); obj_to_char(obj, ch); sprintf(buf, "Poof! You create %s.\r\n", obj->short_description); send_to_char(buf, ch); } else /*there is a target for load*/ { if (!(recipient=get_char_vis(ch, rec_buf, FIND_CHAR_WORLD))) { sprintf(buf,"%s is not in the world.\r\n",rec_buf); send_to_char(buf, ch); return; } else { obj = read_object(r_num, REAL); load_to_recipient(ch, recipient, obj); } } /*there is a load target*/ }