Beispiel #1
0
/* updated for the new display type 5/1/02 */
void display_news( CHAR_DATA *ch, NEWS *news, NEWS_TYPE *type )
{
  pager_printf_color( ch, "\n\r&g--------------------------------------\n\r" );
  pager_printf_color( ch, type->header);
  pager_printf_color( ch, "&g--------------------------------------\n\r" );
  pager_printf_color( ch, NEWS_HEADER_READ);
  sprintf( local_buf, "&g(&W%2d&g)  &W%-12s &%-11s  &W%s&g\n\r", news->number, news->name, news->date, news->title );
  pager_printf_color( ch, local_buf );
  pager_printf_color( ch, "\n\r" );
  if ( news->post[0] != '\0' )
        pager_printf_color( ch, news->post );
  else
        pager_printf_color( ch, "&gNo further information.\n\r" );
  pager_printf_color( ch, "&g--------------------------------------\n\r" );
  pager_printf_color( ch, "\n\r" );
  return;
}
Beispiel #2
0
/* updated for the new display type 5/1/02 */
void display_news( CHAR_DATA * ch, NEWS * news, NEWS_TYPE * type )
{
   pager_printf_color( ch, "\r\n&g--------------------------------------\r\n" );
   send_to_pager( type->header, ch );
   pager_printf_color( ch, "&g--------------------------------------\r\n" );
   send_to_pager( NEWS_HEADER_READ, ch );
   pager_printf_color( ch, "&g(&W%2d&g)  &W%-12s &%-11s  &W%s&g\r\n", news->number, news->name, news->date, news->title );
   pager_printf_color( ch, "\r\n" );
   if( news->post[0] != '\0' )
      send_to_pager( news->post, ch );
   else
      pager_printf_color( ch, "&gNo further information.\r\n" );
   pager_printf_color( ch, "&g--------------------------------------\r\n" );
   pager_printf_color( ch, "\r\n" );
   return;
}
Beispiel #3
0
/*
 * display the news entry from the command hook -Nopey
 */
void display_news_type( CHAR_DATA * ch, NEWS_TYPE * type, char *argument )
{
   if( !type->first_news )
   {
      send_to_char_color( "&gThere are currently no news items for this news type.\r\n", ch );
      return;
   }

   if( argument[0] == '\0' || !str_cmp( argument, "all" ) )
   {
      bool all_news = FALSE;
      NEWS *news = NULL;
      int x = type->last_news->number, y = NEWS_VIEW;
      int skipper = ( x - y );

      if( !str_cmp( argument, "all" ) )
         all_news = TRUE;

      pager_printf_color( ch, "\r\n&g--------------------------------------\r\n" );
      if( type->header )
         send_to_pager( type->header, ch );
      pager_printf_color( ch, "&g--------------------------------------\r\n" );
      send_to_pager( NEWS_HEADER_ALL, ch );

      for( news = type->first_news; news; news = news->next )
      {
         if( !all_news )
         {
            if( skipper > -1 )
            {
               skipper--;
               continue;
            }
         }
         pager_printf_color( ch, "&g(&W%2d&g)  &W%-12s &%-11s  &W%s&g\r\n", news->number, news->name, news->date,
                             news->title );
      }

      if( !all_news )
      {
         if( type->last_news->number == 1 )
            pager_printf_color( ch, "&g\r\nThere is one news item.\r\n" );
         else if( type->last_news->number > NEWS_VIEW - 1 )
            pager_printf_color( ch,
                                "\r\n&gThere are &w%d&g total items, the oldest of which are not listed here.\r\nUse '&w%s all&g' to list them all.&g\r\n",
                                type->last_news->number, type->cmd_name );
         else
            pager_printf_color( ch, "\r\n&gThere are &w%d&g total items.\r\n", type->last_news->number );
         pager_printf_color( ch, "\r\n&gTo read individual items type '&w%s <number>&g'.\r\n", type->cmd_name );
         return;
      }
      pager_printf_color( ch, "\r\n&gTo read individual items type '&w%s <number>&g'.\r\n", type->cmd_name );
   }

   {
      NEWS *news = NULL;

      if( ( news = grab_news( type, argument ) ) == NULL )
      {
         if( str_cmp( argument, "all" ) )
            send_to_char_color( "&g\r\nThat's not a news post number.\r\nUse '&wnews&g' to view them.\r\n", ch );
         return;
      }
      display_news( ch, news, type );
      return;
   }
}
Beispiel #4
0
/* olc editnews command */
void do_editnews( CHAR_DATA* ch, const char* argument)
{
   char arg[MAX_INPUT_LENGTH];

   if( IS_NPC( ch ) || !IS_IMMORTAL( ch ) )
   {
      send_to_char( "Huh?\r\n", ch );
      return;
   }

   set_char_color( AT_GREEN, ch );

   switch ( ch->substate )
   {
      default:
         break;

      case SUB_NEWS_POST:
      {
         NEWS *news = NULL;

         news = ( NEWS * ) ch->dest_buf;
         STRFREE( news->post );
         news->post = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         renumber_news(  );
         save_news(  );
         return;
      }
         break;

      case SUB_NEWS_EDIT:
      {
         NEWS *news = NULL;

         news = ( NEWS * ) ch->dest_buf;
         STRFREE( news->post );
         news->post = copy_buffer( ch );
         stop_editing( ch );
         ch->substate = ch->tempnum;
         renumber_news(  );
         save_news(  );
         return;
      }
         break;
   }

   argument = one_argument( argument, arg );

   if( arg[0] == '\0' )
   {
      send_to_char( "Syntax: editnews addtype <name>\r\n"
                    "        editnews addnews <type> <subject>\r\n"
                    "        editnews removetype <number>\r\n"
                    "        editnews removenews <type> <number>\r\n"
                    "        editnews edittype <field> <value>\r\n"
                    "        editnews editnews <type> <number> <new subject [optional]>\r\n"
                    " Fields being one of the following:\r\n" " name header cmd_name level\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "save" ) )
   {
      renumber_news(  );
      save_news(  );
      send_to_char( "News saved.\r\n", ch );
      return;
   }

   if( !str_cmp( arg, "addtype" ) )
   {
      NEWS_TYPE *type = NULL;

      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews addtype <name>\r\n", ch );
         return;
      }

      if( top_news_type >= NEWS_MAX_TYPES )
      {
         send_to_char( "There are too many news types.\r\n", ch );
         return;
      }

      CREATE( type, NEWS_TYPE, 1 );
      type->name = STRALLOC( argument );
      type->cmd_name = STRALLOC( argument );
      type->vnum = top_news_type++;
      type->level = -1;

      news_command_table[type->vnum] = STRALLOC( type->cmd_name );

      LINK( type, first_news_type, last_news_type, next, prev );
      ch_printf( ch, "Newstype '%s' created.\r\n", argument );
      return;
   }

   if( !str_cmp( arg, "removetype" ) )
   {
      NEWS_TYPE *type = NULL;
      NEWS *news = NULL, *news_next;

      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews removetype <name>\r\n", ch );
         return;
      }

      if( ( type = figure_type( argument ) ) == NULL )
      {
         send_to_char( "Invaild newstype.\r\n", ch );
         return;
      }

      UNLINK( type, first_news_type, last_news_type, next, prev );
      STRFREE( type->name );
      STRFREE( type->header );
      STRFREE( type->cmd_name );
      STRFREE( news_command_table[type->vnum] );
      STRFREE( news_command_table[type->level] );

      for( news = type->first_news; news; news = news_next )
      {
         news_next = news->next;

         UNLINK( news, type->first_news, type->last_news, next, prev );
         STRFREE( news->name );
         STRFREE( news->title );
         STRFREE( news->date );
         STRFREE( news->post );
         DISPOSE( news );
      }

      DISPOSE( type );
      --top_news_type;
      renumber_news(  );
      save_news(  );
      ch_printf( ch, "Newstype '%s' removed.\r\n", argument );
      return;
   }

   if( !str_cmp( arg, "edittype" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      char arg3[MAX_INPUT_LENGTH];
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      argument = one_argument( argument, arg3 );
      if( arg2[0] == '\0' || arg3[0] == '\0' )
      {
         send_to_char( "Syntax: editnews edittype <type> <field> <value>\r\n", ch );
         send_to_char( "Fields being one of the following:\r\n" "name header cmd_name level\r\n", ch );
         return;
      }

      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype.\r\n", ch );
         return;
      }

      if( !str_cmp( arg3, "cmd_name" ) )
      {
         type->cmd_name = STRALLOC( argument );
         news_command_table[type->vnum] = STRALLOC( type->cmd_name );
         send_to_char( "Cmd_name set.\r\n", ch );
         save_news(  );
         return;
      }
      else if( !str_cmp( arg3, "name" ) )
      {
         type->name = STRALLOC( argument );
         send_to_char( "Name set.\r\n", ch );
         save_news(  );
         return;
      }
      else if( !str_cmp( arg3, "level" ) )
      {
         if( argument[0] == '\0' )
         {
            ch_printf( ch, "%d\r\n", type->level );
            return;
         }
         else
            type->level = atoi( argument );
         send_to_char( "Level set.\r\n", ch );
         save_news(  );
         return;
      }
      else
      {
         send_to_char( "Syntax: editnews edittype <type> <field> <value>\r\n", ch );
         send_to_char( "Fields being one of the following:\r\n" "name header cmd_name level\r\n", ch );
         return;
      }
   }

   if( !str_cmp( arg, "addnews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      NEWS_TYPE *type = NULL;
      NEWS *news = NULL;

      argument = one_argument( argument, arg2 );

      if( arg2[0] == '\0' || argument[0] == '\0' )
      {
         send_to_char( "Syntax: editnews addnews <type> <subject>\r\n", ch );
         return;
      }

      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invaild newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      CREATE( news, NEWS, 1 );
      news->title = STRALLOC( argument );
      news->name = STRALLOC( ch->name );
      news->date = STRALLOC( stamp_time(  ) );
      news->post = STRALLOC( "" );

      /*
       * pop character into a writing buffer 
       */
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;

      ch->substate = SUB_NEWS_POST;
      ch->dest_buf = news;
      start_editing( ch, news->post );
      LINK( news, type->first_news, type->last_news, next, prev );
      return;
   }

   if( !str_cmp( arg, "editnews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      char arg3[MAX_INPUT_LENGTH];
      NEWS *news = NULL;
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      argument = one_argument( argument, arg3 );
      if( arg2[0] == '\0' )
      {
         send_to_char( "Syntax: editnews editnews <type> <number> <new subject [optional]>\r\n", ch );
         return;
      }

      /*
       * changed for new -newstype- indexing - 5/5/02 
       */
      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      if( ( news = grab_news( type, arg3 ) ) == NULL )
      {
         pager_printf_color( ch, "That's not a valid news number.\r\nUse '%s' to view the valid numbers.\r\n",
                             type->cmd_name );
         return;
      }

      /*
       * a changed title 
       */
      if( argument[0] != '\0' )
         news->title = STRALLOC( argument );

      /*
       * new date news was edited 
       */
      news->date = STRALLOC( stamp_time(  ) );
      /*
       * pop character into a writing buffer 
       */
      if( ch->substate == SUB_REPEATCMD )
         ch->tempnum = SUB_REPEATCMD;
      else
         ch->tempnum = SUB_NONE;

      ch->substate = SUB_NEWS_EDIT;
      ch->dest_buf = news;
      start_editing( ch, news->post );
      return;
   }

   if( !str_cmp( arg, "removenews" ) )
   {
      char arg2[MAX_INPUT_LENGTH];
      NEWS *news = NULL;
      NEWS_TYPE *type = NULL;

      argument = one_argument( argument, arg2 );
      if( argument[0] == '\0' || arg2[0] == '\0' )
      {
         send_to_char( "Syntax: editnews remove <number>\r\n", ch );
         return;
      }

      /*
       * changed for new -newstype- indexing - 5/5/02 
       */
      if( ( type = figure_type( arg2 ) ) == NULL )
      {
         send_to_char( "Invalid newstype. Use 'newstypes' to get a valid listing.\r\n", ch );
         return;
      }

      if( ( news = grab_news( type, argument ) ) == NULL )
      {
         send_to_char( "Type 'news' to gain a list of the news numbers.\r\n", ch );
         return;
      }

      UNLINK( news, type->first_news, type->last_news, next, prev );
      STRFREE( news->name );
      STRFREE( news->title );
      STRFREE( news->date );
      STRFREE( news->post );
      DISPOSE( news );
      renumber_news(  );
      save_news(  );
      send_to_char( "News item removed.\r\n", ch );
      return;
   }
}
Beispiel #5
0
/** Function: do_slay
  * Descr   : Slays (kills) a player, optionally sending one of several
  *           predefined "slay option" messages to those involved.
  * Returns : (void)
  * Syntax  : slay (who) [option]
  * Written : v1.0 12/97
  * Author  : Gary McNickle <*****@*****.**>
  * Ported to Smaug 1.02a by: Samson
  * Updated to work with Smaug 1.4 by Samson 8-3-98
  * v2.0 added support for online editing
  */
void do_slay( CHAR_DATA * ch, char *argument )
{
   CHAR_DATA *victim;
   SLAY_DATA *slay;
   char type[MAX_INPUT_LENGTH];
   char who[MAX_INPUT_LENGTH];
   bool found = FALSE;

   if( IS_NPC( ch ) )
   {
      send_to_char( "Mobs can't use the slay command.\r\n", ch );
      return;
   }

   argument = one_argument( argument, who );
   argument = one_argument( argument, type );

   if( !str_prefix( who, "list" ) || who == NULL )
   {
      set_char_color( AT_GREEN, ch );
      send_to_char( "Syntax: slay <victim> [type]\r\n", ch );
      send_to_char( "Where type is one of the above...\r\n", ch );

      send_to_pager_color( "&YSlay 			  &ROwner\r\n", ch );
      send_to_pager_color( "&g-------------------------+---------------\r\n", ch );
      for( slay = first_slay; slay; slay = slay->next )
         pager_printf_color( ch, "&G%-14s	&g%13s\r\n", slay->type, slay->owner );

      send_to_char( "\r\nTyping just 'slay <player>' will work too...\r\n", ch );
      return;
   }

   if( ( victim = get_char_room( ch, who ) ) == NULL )
   {
      send_to_char( "They aren't here.\r\n", ch );
      return;
   }

   if( ch == victim )
   {
      send_to_char( "Suicide is a mortal sin.\r\n", ch );
      return;
   }

   if( !IS_NPC( victim ) && victim->level > ch->level )
   {
      send_to_char( "You cannot slay someone who is above your level.\r\n", ch );
      return;
   }

   if( type[0] == '\0' )
   {
      act( AT_IMMORT, "You brutally slay $N!", ch, NULL, victim, TO_CHAR );
      act( AT_IMMORT, "$n chops you up into little pieces!", ch, NULL, victim, TO_VICT );
      act( AT_IMMORT, "$n brutally slays $N!", ch, NULL, victim, TO_NOTVICT );
      set_cur_char( victim );
      raw_kill( ch, victim );
      return;
   }
   else
   {
      for( slay = first_slay; slay; slay = slay->next )
      {
         if( ( !str_cmp( type, slay->type ) && !str_cmp( "Any", slay->owner ) )
             || ( !str_cmp( slay->owner, ch->name ) && !str_cmp( type, slay->type ) ) )
         {
            found = TRUE;
            act( slay->color, slay->cmsg, ch, NULL, victim, TO_CHAR );
            act( slay->color, slay->vmsg, ch, NULL, victim, TO_VICT );
            act( slay->color, slay->rmsg, ch, NULL, victim, TO_NOTVICT );
            set_cur_char( victim );
            raw_kill( ch, victim );
            return;
         }
      }
   }

   if( !found )
      send_to_char
         ( "&RSlay type not defined, or not owned by you. Type \"slay list\" for a complete listing of types available to you.\r\n",
           ch );

   return;
}  /* end of func: "do_slay" */