perm_it.c

skylib_fluffos_v3/mudlib/cmds/player/perm_it.c · 1.9 KB

From the archive skylib_fluffos_v3.zip

Download the archive   « Back to the archive contents

/*Thanks to Turrican, Gruper, and Mansarde, without whom I would have given up on this project.
  - Aragorn                                                                                   */

inherit COMMAND_BASE;

int cmd( object player ) {

  object *corpses, corpse;
  int i;
  
  /* Obviously we'll only want to search player corpses */
  corpses = filter( children( "/obj/corpse" ),
                    (: $1 && $1->query_property("player" ) :) );

  /* Now we look for corpses they own */
  corpses = filter( corpses,
                    (: $1 &&
                       $1->query_ownership() == $( this_player()->query_name() ) :) );

  if( sizeof( corpses ) ) { 
    foreach( corpse in corpses ){
      if ( member_array( player->query_name(), corpse->query_permitted() ) != -1 ){ /*Let's see if any of these corpses have already been permitted*/
        i++;

      } else {
        /*
         * The heart of the command, this adds the name to the corpses
         * array of permitted players
         */
        corpse->give_permission( player->query_name() );
      }
    }

  } else { 
    /* Whoops, we don't have any corpses loaded */
    add_failed_mess("You don't seem to have a corpse!  Why not die and try "
                    "again?%^RESET%^\n");
    return 0;
  }           

  /* Let them know if we were successful or if we just wasted our time */
  if( i == sizeof( corpses ) ){
    write(capitalize(player->query_name()) + " is already permitted to "
          "remove items from your corpse.%^RESET%^\n" );
  } else { 
    write(capitalize(player->query_name()) + " is now permitted to "
          "remove items from your corpse.%^RESET%^\n" );
    tell_object(player, "%^BOLD%^%^GREEN%^You now have permission to get "
                "items from " + this_player()->query_cap_name() +
                "'s corpse.%^RESET%^\n");
  }
  return 1;
} 

mixed *query_patterns() {
  return ({ "<indirect:player>", (: cmd($1[0]) :) });
} /* query_patterns() */

Site Stats

Snippets: 1791
Codebases: 571