Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, DotBot

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » AFKMud Support & Development » Holiday OLC code
Forum Rules | Mark all | Recent Posts

Holiday OLC code
< Newer Topic :: Older Topic > Holiday Online Creation, by - Txzee

Pages:<< prev 1 next >>
Post is unread #1 May 20, 2005, 12:02 pm   Last edited May 21, 2005, 4:24 am by Txzeenath
Go to the top of the page
Go to the bottom of the page

Txzeenath
Apprentice
GroupMembers
Posts86
JoinedJul 24, 2004

I hate having to edit system files.. so I wrote this out.. you're free to use it as you wish.. however this is for AFKMud 1.7 calendar system, so any heavily modified calendar systems or SmaugFUSS won't be able to use this/have any use for it.
.. but than again this IS an afkmud forum, so that shouldn't be a problem now should it.

This might be sloppy or badly written as your standards go... but I wrote it from scratch with "pico" ... so i'd say it's a pretty good job hehe.

There may be some security pieces that I used for accurate testing, but can be taken out to shorten it, but from what i've tested, it's fully functioning so they shouldn't have any bad affects.

This was coded for my use only, so you will have to supply your own level checks if you want this to be more restrictive

This is one of the few pieces of code i've released :-p perhaps this might even get into the AFKMud code (:wink: Samson)

/* Holiday OLC command - (c)Andrew Wilkie May-20-2005*/
/* Calendar code (c)The Alsherok Team*/
CMDF do_setholiday( CHAR_DATA * ch, char *argument )
{
   HOLIDAY_DATA *day, *newday;
   int count = 0;
   int x = 0;
   char arg1[MIL], arg2[MIL], arg3[MIL];

   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   argument = one_argument( argument, arg3 );

   if( arg1 == '\0' || !str_cmp( arg1, " " ) )
   {
      send_to_char( "Syntax : setholiday <name> <field> <argument>\n\r", ch );
      send_to_char( "Field can be : day name create announce save delete\n\r", ch );
      return;
   }

/* Save em all.. saves the work of saving individual 
   holidays when mass-creating or editing*/
   if( !str_cmp( arg1, "save" ) )
   {
      save_holidays(  );
      send_to_char( "Holiday chart saved.\n\r", ch );
      return;
   }

/* Create a new holiday by name arg1 */
   if( !str_cmp( arg2, "create" ) )
   {
      for( day = first_holiday; day; day = day->next )
         count++;
      for( day = first_holiday; day; day = day->next )
      {
         if( !str_cmp( arg1, day->name ) )
         {
            send_to_char( "A holiday with that name exists already !\n\r", ch );
            return;
         }
      }

      if( count >= sysdata.maxholiday )
      {
         send_to_char( "There are already too many holidays!\n\r", ch );
         return;
      }

      CREATE( newday, HOLIDAY_DATA, 1 );
      newday->name = str_dup( arg1 );
      newday->day = time_info.day;
      newday->month = time_info.month;
      newday->announce = str_dup( "Today is the holiday of when some moron forgot to set the announcement forthis one !" );
      LINK( newday, first_holiday, last_holiday, next, prev );
      send_to_char( "Holiday created\n\r", ch );
      return;
   }

/* Now... let's find that holiday */

   for( day = first_holiday; day; day = day->next )
   {
      if( !str_cmp( day->name, arg1 ) )
         break;
   }

/* Anything match? */
   if( !day )
   {
      send_to_char( "Which holiday was that ?\n\r", ch );
      return;
   }

/* Set the day */

   if( !str_cmp( arg2, "day" ) )
   {
      if( arg3 == '\0' || !is_number( arg3 ) || atoi( arg3 ) > sysdata.dayspermonth || atoi( arg3 ) <= 1 )
      {
         ch_printf( ch, "You must specify a numeric value : %d - %d", 1, sysdata.dayspermonth );
         return;
      }

/* What day is it?... FRIDAY!.. oh... no... it's.. arg3? */
      day->day = atoi( arg3 );
      send_to_char( "Day changed\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "month" ) )
   {
/* Go through the months and find arg3 */

      if( arg3 == '\0' || !is_number( arg3 ) || atoi( arg3 ) > sysdata.monthsperyear || atoi( arg3 ) <= 1 )
      {
         send_to_char( "You must specify a valid month number:\n\r", ch );

/* List all the months with a counter next to them*/
         count = 1;
         while( month_name[x] != '\0' && str_cmp(month_name[x], " ";) && x < sysdata.monthsperyear)

         {
            ch_printf( ch, "&[red](&[white]%d&[red])&[yellow]%s\n\r", count, month_name[x] );
            x++;
            count++;
         }
return;
      }


/* What's the month? */
      day->month = atoi( arg3 );
      send_to_char( "Month changed\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "announce" ) )
   {
      if( arg3 == '\0' || !str_cmp( arg3, " " ) || is_number( arg3 ) )
      {
         send_to_char( "Set the annoucement to what ?\n\r", ch );
         return;
      }

/* Set the announcement */
      DISPOSE( day->announce );
      day->announce = str_dup( arg3 );
      send_to_char( "Announcement changed\n\r", ch );
      return;
   }

/* Change the name */
   if( !str_cmp( arg2, "name" ) )
   {
      if( arg3 == '\0' || !str_cmp( arg3, " " ) || is_number( arg3 ) )
      {
         send_to_char( "Set the name to what ?\n\r", ch );
         return;
      }

/* Release the good...err... name */
      DISPOSE( day->name );
      day->name = str_dup( arg3 );
      send_to_char( "Name changed\n\r", ch );
      return;
   }

   if( !str_cmp( arg2, "delete" ) )
   {
      if( str_cmp( arg3, "yes" ) )
      {
         send_to_char( "If you are sure, use 'delete yes'\n\r", ch );
         return;
      }

      free_holiday( day );
      send_to_char( "&RHoliday deleted\n\r", ch );
      return;
   }

   send_to_char( "Syntax: setholiday <name> <field> <argument>\n\r", ch );
   send_to_char( "Field can be: day name create announce save delete\n\r", ch );
   return;
}
       
Pages:<< prev 1 next >>