Written by Krylan of DevMUD - df.moocowpenguin.com 9700 Disclaimer ---------- This code was written on an SWFotE FUSS. I am in no way responsible for any damage this causes. It's a very simple piece of code, and I do not believe it should cause any damage. This should work on any SMAUG derivative. Description ----------- This code adds keypads to your MUD. All you must do is set the exit flag to keypad and set the doors Key to the number you want to use for your keypad code. Setcode is for players to change the code at will. (un)Lock is the syntax. You can still have a regular key and lock. Any questions can be directed to me on the MUD. (1) act_move.c Add this: void do_setcode( CHAR_DATA *ch, char *argument ) { AREA_DATA *area; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; EXIT_DATA *pexit; EXIT_DATA *pexit_rev; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if ( arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0' ) { send_to_char( "&RUsage: setcode \n\r", ch ); return; } if ( ( pexit = find_door( ch, arg1, TRUE ) ) != NULL ) { if ( !IS_SET(pexit->exit_info, EX_ISDOOR) ) { send_to_char( "It only works on a door!\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_KEYPAD) ) { send_to_char( "The door isn't equiped with a keypad!\n\r", ch ); return; } if ( pexit->key != atoi( arg2 ) ) { send_to_char( "Thats not the current code!\n\r", ch ); return; } if ( atoi( arg3 ) < 1000 || atoi( arg3 ) > 99999 ) { send_to_char( "A monitor by the door flashes on: 'Invalid Current Code'\n\r", ch ); return; } pexit->key = atoi(arg3); echo_to_room( AT_YELLOW, ch->in_room, "A monitor by the door flashes on: 'Code Changed'"); if ( (pexit_rev = pexit->rexit) != NULL && pexit_rev->to_room == ch->in_room ) { pexit_rev->key = atoi(arg3); echo_to_room( AT_YELLOW, pexit->to_room, "A monitor by the door flashes on: 'Code Changed'"); } area = ch->in_room->area; fold_area( area, area->filename, FALSE ); if ( pexit->to_room->area != area ) fold_area( pexit->to_room->area, pexit->to_room->area->filename, FALSE ); return; } ch_printf( ch, "You don't see %s here.\n\r", arg1 ); return; } Replace do_lock and do_unlock with these: void do_lock( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; OBJ_DATA *obj; EXIT_DATA *pexit; int code = 0; argument = one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Lock what?\n\r", ch ); return; } if ( ( pexit = find_door( ch, arg, TRUE ) ) != NULL ) { /* 'lock door' */ if ( !IS_SET(pexit->exit_info, EX_ISDOOR) ) { send_to_char( "You can't do that.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_CLOSED) ) { send_to_char( "It's not closed.\n\r", ch ); return; } if ( pexit->key < 0 ) { send_to_char( "It can't be locked.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_KEYPAD) ) { if ( !has_key( ch, pexit->key) && !IS_IMMORTAL(ch) ) { send_to_char( "You lack the key.\n\r", ch ); return; } } else { if ( argument[0] == '\0' ) { send_to_char("&RThis is a keypad-protected doorway.\n\r&RUsage: lock \n\r", ch ); return; } code = atoi( argument ); if ( code != pexit->key ) { echo_to_room( AT_YELLOW, ch->in_room, "A monitor by the door flashes on: 'Access Code Invalid'"); if ( pexit->to_room ) echo_to_room( AT_YELLOW, pexit->to_room, "A monitor by the door flashes on: 'Access Code Invalid'"); return; } } if ( IS_SET(pexit->exit_info, EX_LOCKED) ) { send_to_char( "It's already locked.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_SECRET) || (pexit->keyword && nifty_is_name( arg, pexit->keyword )) ) { send_to_char( "*Click*\n\r", ch ); act( AT_ACTION, "$n locks the $d.", ch, NULL, pexit->keyword, TO_ROOM ); set_bexit_flag( pexit, EX_LOCKED ); return; } } if ( ( obj = get_obj_here( ch, arg ) ) != NULL ) { /* 'lock object' */ if ( obj->item_type != ITEM_CONTAINER ) { send_to_char( "That's not a container.\n\r", ch ); return; } if ( !IS_SET(obj->value[1], CONT_CLOSED) ) { send_to_char( "It's not closed.\n\r", ch ); return; } if ( obj->value[2] < 0 ) { send_to_char( "It can't be locked.\n\r", ch ); return; } if ( !has_key( ch, obj->value[2] ) ) { send_to_char( "You lack the key.\n\r", ch ); return; } if ( IS_SET(obj->value[1], CONT_LOCKED) ) { send_to_char( "It's already locked.\n\r", ch ); return; } SET_BIT(obj->value[1], CONT_LOCKED); send_to_char( "*Click*\n\r", ch ); act( AT_ACTION, "$n locks $p.", ch, obj, NULL, TO_ROOM ); return; } ch_printf( ch, "You see no %s here.\n\r", arg ); return; } void do_unlock( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; OBJ_DATA *obj; EXIT_DATA *pexit; int code = 0; argument = one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Unlock what?\n\r", ch ); return; } if ( ( pexit = find_door( ch, arg, TRUE ) ) != NULL ) { /* 'unlock door' */ if ( !IS_SET(pexit->exit_info, EX_ISDOOR) ) { send_to_char( "You can't do that.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_CLOSED) ) { send_to_char( "It's not closed.\n\r", ch ); return; } if ( pexit->key < 0 ) { send_to_char( "It can't be unlocked.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_KEYPAD) ) { if ( !has_key( ch, pexit->key) && !IS_IMMORTAL(ch) ) { send_to_char( "You lack the key.\n\r", ch ); return; } } else { if ( argument[0] == '\0' ) { send_to_char("&RThis is a keypad-protected doorway.\n\r&RUsage: unlock \n\r", ch ); return; } code = atoi( argument ); if ( code != pexit->key ) { echo_to_room( AT_YELLOW, ch->in_room, "A monitor by the door flashes on: 'Access Code Invalid'"); if ( pexit->to_room ) echo_to_room( AT_YELLOW, pexit->to_room, "A monitor by the door flashes on: 'Access Code Invalid'"); return; } } if ( !IS_SET(pexit->exit_info, EX_LOCKED) ) { send_to_char( "It's already unlocked.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_SECRET) || (pexit->keyword && nifty_is_name( arg, pexit->keyword )) ) { send_to_char( "*Click*\n\r", ch ); act( AT_ACTION, "$n unlocks the $d.", ch, NULL, pexit->keyword, TO_ROOM ); remove_bexit_flag( pexit, EX_LOCKED ); return; } } if ( ( obj = get_obj_here( ch, arg ) ) != NULL ) { /* 'unlock object' */ if ( obj->item_type != ITEM_CONTAINER ) { send_to_char( "That's not a container.\n\r", ch ); return; } if ( !IS_SET(obj->value[1], CONT_CLOSED) ) { send_to_char( "It's not closed.\n\r", ch ); return; } if ( obj->value[2] < 0 ) { send_to_char( "It can't be unlocked.\n\r", ch ); return; } if ( !has_key( ch, obj->value[2] ) ) { send_to_char( "You lack the key.\n\r", ch ); return; } if ( !IS_SET(obj->value[1], CONT_LOCKED) ) { send_to_char( "It's already unlocked.\n\r", ch ); return; } REMOVE_BIT(obj->value[1], CONT_LOCKED); send_to_char( "*Click*\n\r", ch ); act( AT_ACTION, "$n unlocks $p.", ch, obj, NULL, TO_ROOM ); return; } ch_printf( ch, "You see no %s here.\n\r", arg ); return; } (2) mud.h Underneath #define EX_xLOOK BV26 Add #define EX_KEYPAD BV27 (3)mud.h and tables.c Add the DECLARE_DO_FUN for setcode and the lines in tables.c. (4) Make clean and recompile.