Ok here it is, Joe's very own locker snippet. Use it as you will, all I ask is that you let me know if you use it and that you give me a credit for it. 1. Create a locker object in an area file. Below is the one I use. #3000 locker~ a locker~ a locker~ wood~ container FHMOTYZ AP 0 0 0 0 0 150 0 1000 P 2. Add the following lines of code to your source IN MERC.H ------------------------------------------------------- /* act_obj.c */ bool can_loot args( (CHAR_DATA *ch, OBJ_DATA *obj) ); ++//Joe:Lockers Required for locker code ++void show_list_to_char args( ( OBJ_DATA *list, CHAR_DATA *ch, bool fShort, bool fShowNothing ) ); ------------------------------------------------------- //Add this one in correct place ++/* locker.c */ ++ ++//Joe:Lockers Declaration for useful functions ++OBJ_DATA *get_obj_locker_room args(( CHAR_DATA *ch, sh_int vnum )); ++OBJ_DATA *get_locker args (( CHAR_DATA *ch)); ++////////////////////////////////////// ------------------------------------------------------- //Add this anywhere //Joe:Lockers These defines locker object and room vnums #define LOCKER_VNUM 3000 #define LOCKER_ROOM 3003 //Set this to your temple pit or whatever ------------------------------------------------------- IN FIGHT.C ------------------------------------------------------- if (IS_SET(obj->extra_flags,ITEM_ROT_DEATH) && !floating) { obj->timer = number_range(5,10); REMOVE_BIT(obj->extra_flags,ITEM_ROT_DEATH); } REMOVE_BIT(obj->extra_flags,ITEM_VIS_DEATH); ++//Joe:Lockers OK this determines if obj is chars's locker obj. If so drop it in room so it can be placed back on char ++ if (obj->pIndexData->vnum==LOCKER_VNUM) ++ obj_to_room(obj,ch->in_room ); ++///////////////////////////////////////////////////////////////////////////////////// else if ( IS_SET( obj->extra_flags, ITEM_INVENTORY ) ) extract_obj( obj ); ------------------------------------------------------- death_cry( victim ); make_corpse( victim ); ++//Joe:Lockers Ok locker should have been dropped in room. Recover locker before char sent to death room ++ if ( (obj = get_obj_locker_room(victim,3000)) != NULL ) //ooops locker not in room. how did that happen? ++ obj_from_room(obj);//Get locker from room ++////////////////////////////////////////////// if ( IS_NPC(victim) ) { ------------------------------------------------------- //This must go in right place or else locker gets deleted victim->mana = UMAX( 1, victim->mana ); victim->move = UMAX( 1, victim->move ); /* save_char_obj( victim ); we're stable enough to not need this :) */ ++//Joe:Lockers Now char is in death room etdc place locker back on him ++ if (obj->pIndexData->vnum==3000) ++ obj_to_char(obj,victim); ++//////////////////////////////////////// return; ------------------------------------------------------- IN INTERP.C { "list", do_list, POS_RESTING, 0, LOG_NORMAL, 1 }, { "lock", do_lock, POS_RESTING, 0, LOG_NORMAL, 1 }, ++//Joe:Lockers ++ { "locker", do_locker,POS_STANDING, 0,LOG_NORMAL,1}, ++/////////////////////////// { "open", do_open, POS_RESTING, 0, LOG_NORMAL, 1 }, { "pick", do_pick, POS_RESTING, 0, LOG_NORMAL, 1 }, ------------------------------------------------------- IN INTERP.H DECLARE_DO_FUN( do_lock ); ++//Joe:Lockers ++DECLARE_DO_FUN(do_locker); 3. Add the following code in a file called "locker.c" #if defined(macintosh) #include <types.h> #else #include <sys/types.h> #include <sys/time.h> #endif #include <io.h> #include <direct.h> #include <ctype.h> #include <errno.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include "merc.h" #include "interp.h" //Joe:Lockers Check if theres a locker in the room and if so return the obj data OBJ_DATA *get_obj_locker_room( CHAR_DATA *ch, sh_int vnum ) { OBJ_DATA *obj; for ( obj = ch->in_room->contents; obj; obj = obj->next_content ) if ( obj->pIndexData->vnum == vnum ) return obj; return NULL; } /* * Find an obj in player's inventory without checking for invis blind etc.... Used for lockers */ OBJ_DATA *get_locker( CHAR_DATA *ch) { char arg[MAX_INPUT_LENGTH]; OBJ_DATA *obj; for ( obj = ch->carrying; obj != NULL; obj = obj->next_content ) { if (obj->pIndexData->vnum==LOCKER_VNUM) return obj; } return NULL; } void do_locker (CHAR_DATA *ch,char *argument) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char buf[100]; OBJ_DATA *obj; OBJ_DATA *container; argument=one_argument(argument,arg1); argument=one_argument(argument,arg2); if (ch->in_room->vnum!=LOCKER_ROOM) { send_to_char("Go the locker room eeeediot!!\n\r",ch); return; } if ( ( container=get_locker(ch))==NULL) { send_to_char("Locker, what locker?",ch); return; } if (!str_cmp(arg1,"get")) { //do the locker get command /* 'get obj container' */ obj = get_obj_list( ch, arg2, container->contains ); if ( obj == NULL ) { act( "Your locker doesn't contain that.",ch, NULL, arg2, TO_CHAR ); return; } get_obj( ch, obj, container ); } else if(!str_cmp(arg1,"put")) { //you guessed it, do the the locker put command //First get the object from inventory if ( ( obj = get_obj_carry( ch, arg2, ch ) ) == NULL ) { send_to_char( "You do not have that item.\n\r", ch ); return; } //Now check to see if meets conditions if ( obj->item_type==ITEM_CONTAINER) { send_to_char( "Containers are not allowed in lockers.\n\r", ch ); return; } if ( !can_drop_obj( ch, obj ) ) { send_to_char( "You can't let go of it.\n\r", ch ); return; } //Put obj in locker obj_from_char( obj ); obj_to_obj( obj, container ); act( "$n puts $p in $s locker.", ch, obj, container, TO_ROOM ); act( "You put $p in your locker.", ch, obj, container, TO_CHAR ); } else if(!str_cmp(arg1,"list")) { //do the locker list command send_to_char("Your locker contains:\n\r",ch); show_list_to_char(container-> ,ch,TRUE,TRUE); return; } else { //dumb fucks cant spell and need teaching :) send_to_char("Try this syntax instead :-\nlocker put *object*\nlocker get *object*\nlocker list\n",ch); } return; } 4.Compile and thats the code dealt with. Now I added a line in the creation process to give the char a locker obj at startup. You could give lockers to players when you feel like. The code doesnt check for weight, max items yet but will do in next version. Ensure the locker object is INVIS and very high level so player cant see the damn thing, obviously lockers will save with pfile and are automatically given back to player when they are killed etc. Might want to check burnproof etc Any problems give me a call. curanir@phoeniisrhyn.fsnet.co.uk ICQ 17134824 Enjoy