Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
Bing, AhrefsBot

Members: 0
Guests: 26
Stats
Files
Topics
Posts
Members
Newest Member
489
3,792
19,646
597
Aileenutz

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Codebases » LoP Codebase » Lottery
Forum Rules | Mark all | Recent Posts

Lottery
< Newer Topic :: Older Topic > Thoughts and ideas on the lottery?

Pages:<< prev 1, 2, 3, 4 next >>
Post is unread #21 Sep 2, 2013 2:48 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
im not against it lol did have it set up to show when you bought them, problem is if you buy 50 quickpicks it is spammy. Maybe make it so they can see the tickets they bought if they type lottery ?

Post is unread #22 Sep 2, 2013 2:56 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
yeah that would be cool :)

Post is unread #23 Sep 2, 2013 3:03 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
ok try
changing
         lottery->jackpot += (int)( lottery->price / (double)( 100 / lottery->jpercent ) );

to this
         lottery->jackpot += (int)( (double)( ( lottery->price * lottery->jpercent ) / 100 ) );

Problem is that this one works better but is going to wrap way quicker if the price is to high lol.

Post is unread #24 Sep 2, 2013 3:07 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
The displaying numbers would just be cool and give it a realistic feeling, you know.

Also the jackpot percent thing isn't that big of a deal, but its a nice feature that would be nice if it worked.

Next do you think you could show me an example of the who displaying thing. I was going to make a function called display_nextdrawing and call it to the who code, just unsure how I would go about going through every lottery event and picking which one draws next, not to mention how to handle the off chance that two or more lottery events decided to have the same draw time.

next I was wondering about if the tickets are cleared after every drawing (even if noone wins). Like a real lottery system and if there was way that you disable and re-enable that function.

And last I am unsure how players are told they have winnings waiting for them. I was thinking of having a reminder that you have winnings you can claim on login, and one sent to you when the numbers are actually draw. But again I am unsure how I would go about doing either of those things.

Post is unread #25 Sep 2, 2013 3:44 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
find
   do_help( ch, (char *)"lottery" );
}

void lottery_update( void )

At the bottom of do_lottery and change it to
   lottery = find_lottery( arg );
   if( !lottery )
      do_help( ch, (char *)"lottery" );
   else
   {
      int cnt = 1, maxcnt = 50, oncnt = 0;

      /* If just one arg start at that number and show up to 50 */
      /* Don't allow cnt to be less than 1 */
      argument = one_argument( argument, arg );
      if( arg != NULL && arg[0] != '\0' )
         cnt = UMAX( 0, atoi( arg ) );

      /* If there is another arg adjust the maxcnt */
      /* Don't allow maxcnt to be less than 0 or more than 100 */
      argument = one_argument( argument, arg );
      if( arg != NULL && arg[0] != '\0' )
         maxcnt = URANGE( 0, ( atoi( arg ) - cnt ), 100 );

      for( lhistory = lottery->first_lhistory; lhistory; lhistory = lhistory->next )
      {
         if( lhistory->drawn )
            ch_printf( ch, "Winning numbers: %s.\r\n", lhistory->winning_numbers ? lhistory->winning_numbers : "" );
         else
            ch_printf( ch, "DrawTime         %s\r\n", distime( lottery->timetodraw ) );

         for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner->next )
         {
            if( str_cmp( lwinner->winner, ch->name ) )
               continue;
            ++oncnt;
            if( oncnt < cnt )
               continue;
            if( oncnt == cnt )
               ch_printf( ch, "   Showing tickets %d to %d.\r\n", cnt, ( cnt + maxcnt ) );
            if( maxcnt-- < 0 )
               break;

            ch_printf( ch, "   %3d Numbers: %s ", oncnt, lwinner->used_numbers );
            if( lhistory->drawn && lwinner->winnings > 0 )
               ch_printf( ch, "Winnings: %d", lwinner->winnings );
            send_to_char( "\r\n", ch );
         }
      }
   }
}

void lottery_update( void )

That makes it show fairly nice and gives them control of what ones they see.

Post is unread #26 Sep 2, 2013 3:57 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
try this out
char *display_nextdrawing( void )
{
   LOTTERY_DATA *lottery, *lotdraw = NULL;
   time_t nextdraw;
   static char buf[MIL];
   bool foundfirst = false;

   for( lottery = first_lottery; lottery; lottery = lottery->next )
   {
      /* There is some reason it hasn't been drawn so skip it */
      if( lottery->drawtime < current_time )
         continue;
      if( !foundfirst || lottery->drawtime < nextdraw )
      {
         lotdraw = lottery;
         nextdraw = lottery->drawtime;
      }
      foundfirst = true;
   }
   if( !lotdraw )
      snprintf( buf, sizeof( buf ), "%s", "There is currently no lottery set to be drawn." );
   else
      snprintf( buf, sizeof( buf ), "%s will be drawn at %s.", lotdraw->name, distime( nextdraw ) );

   return buf;
}

then somewhere you could just do a string in who showing what this sends it.

Post is unread #27 Sep 2, 2013 4:06 pm   Last edited Sep 2, 2013 4:07 pm by Remcon
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 

next I was wondering about if the tickets are cleared after every drawing (even if noone wins). Like a real lottery system and if there was way that you disable and re-enable that function.

No disabling or re-enableing it, it will clear when completely empty on it (been drawn no winners etc...)


And last I am unsure how players are told they have winnings waiting for them. I was thinking of having a reminder that you have winnings you can claim on login, and one sent to you when the numbers are actually draw. But again I am unsure how I would go about doing either of those things.

They aren't currently told at all. it wouldn't be to hard you can take a look at the "claim" part which goes through everything and gives them their winnings, at the point where you find any winning for them just return true and tell them they have winnings. sort of like this
bool has_winnings( CHAR_DATA *ch )
{
   LOTTERY_DATA *lottery;
   LHISTORY_DATA *lhistory;
   LWINNER_DATA *lwinner;

   if( !ch )
      return false;

   for( lottery = first_lottery; lottery; lottery = lottery->next )
   {
      for( lhistory = lottery->first_lhistory; lhistory; lhistory = lhistory->next )
      {
         if( !lhistory->drawn )
            continue;

         for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner->next )
         {
            if( !str_cmp( lwinner->winner, ch->name ) )
               return true;
         }
      }
   }

   return false;
}

Post is unread #28 Sep 2, 2013 8:44 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Alright the next question is the prize for matches means what you would get lets say if you matched 4 out of 5 for example is that in percent or amount. ?

Post is unread #29 Sep 2, 2013 9:00 pm   Last edited Sep 2, 2013 9:02 pm by Remcon
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
ok lets say you have a price at 100, 5 numbers, 3 matches to win, 20 prize for matches
if you got all 5 numbers you get the jackpot
if you got 4 numbers you get 40
if you got 3 numbers you get 20
for 2 and less nothing

And of course you can set prize for matches higher than price if you want etc... but matches to win should be less than the amount of numbers lol

Post is unread #30 Sep 2, 2013 9:08 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Alright the current Lottery command I have now causes inf loops when I use Lottery Buy weekly quickpick

void do_lottery( CHAR_DATA * ch, char *argument )
{
   LOTTERY_DATA *lottery;
   LHISTORY_DATA *lhistory, *lhistory_next;
   LWINNER_DATA *lwinner, *lwinner_next;
   char arg[MIL], arg2[MIL], quickpick[MSL];
   int claimed = 0, days, hours, mins, drawtime;

   if( !ch || IS_NPC( ch ) )
      return;

   argument = one_argument( argument, arg );
   /* Show all lotterys */
   if( arg == NULL || arg[0] == '\0' )
   {
      for( lottery = first_lottery; lottery; lottery = lottery->next )
      {
         claimed++;

         drawtime = 0;
         days = 0;
         hours = 0;
         mins = 0;
         if( lottery->timetodraw != 0 && lottery->timetodraw > current_time )
         {
            /* How long till the drawing */
            drawtime = ( lottery->timetodraw - current_time );
            while( drawtime > 86400 )
            {
               drawtime -= 86400;
               days++;
            }
            while( drawtime > 3600 )
            {
               drawtime -= 3600;
               hours++;
            }
            while( drawtime > 60 )
            {
               drawtime -= 60;
               mins++;
            }
         }
         ch_printf( ch, "Lottery: %s, Jackpot: %d", lottery->name, lottery->jackpot );
         if( days > 0 || hours > 0 || mins > 0 || drawtime > 0 )
            send_to_char( ", Draws in:", ch );
         if( days > 0 )
            ch_printf( ch, " %d days", days );
         if( hours > 0 )
            ch_printf( ch, " %d hours", hours );
         if( mins > 0 )
            ch_printf( ch, " %d mins", mins );
         if( drawtime > 0 )
            ch_printf( ch, " %d seconds", drawtime );
         send_to_char( ".\r\n", ch );
      }

      if( claimed == 0 )
         send_to_char( "There currently aren't any lotterys you can buy tickets for.\r\n", ch );
      return;
   }

   /* Immortal only stuff*/
   if( IS_IMMORTAL( ch ) && ch->trust > 65)
   {
      if( !str_cmp( arg, "create" ) )
      {
         if( !argument || argument[0] == '\0' )
         {
            send_to_char( "Usage: lottery create .\r\n", ch );
            return;
         }
         lottery = new_lottery( );
         if( !lottery )
         {
            send_to_char( "A new lottery couldn't be created.\r\n", ch );
            return;
         }
         STRSET( lottery->name, argument );

         lhistory = new_lhistory( );
         if( !lhistory )
         {
            send_to_char( "A new history couldn't be created.\r\n", ch );
            free_lottery( lottery );
            return;
         }
         LINK( lhistory, lottery->first_lhistory, lottery->last_lhistory, next, prev );
         add_lottery( lottery );
         save_lotterys( );
         ch_printf( ch, "Lottery %s has been created.\r\n", lottery->name );
         return;
      }

      if( !str_cmp( arg, "delete" ) )
      {
         argument = one_argument( argument, arg );
         if( arg == NULL|| arg[0] == '\0' )
         {
            send_to_char( "Usage: lottery delete .\r\n", ch );
            return;
         }

         lottery = find_lottery( arg );
         if( !lottery )
         {
            send_to_char( "No such lottery to delete.\r\n", ch );
            return;
         }

         remove_lottery( lottery );
         free_lottery( lottery );
         save_lotterys( );
         send_to_char( "You have deleted that lottery.\r\n", ch );
         return;
      }

      if( !str_cmp( arg, "set" ) )
      {
         argument = one_argument( argument, arg );
         if( arg == NULL|| arg[0] == '\0' )
         {
            send_to_char( "Usage: lottery set .\r\n", ch );
            return;
         }

         lottery = find_lottery( arg );
         if( !lottery )
         {
            send_to_char( "No such lottery to set.\r\n", ch );
            return;
         }

         argument = one_argument( argument, arg );
         if( arg == NULL || arg[0] == '\0' )
         {
            int buyers = 0;

            ch_printf( ch, "Name:            %s\r\n", lottery->name );
            ch_printf( ch, "DrawTime         %s\r\n", distime( lottery->timetodraw ) );
            ch_printf( ch, "TimeBetweenDraws %d(In Seconds)\r\n", lottery->timebetweendraws );
            if( !lottery->raffle )
               ch_printf( ch, "Numbers:         %d\r\n", lottery->numbers );
            ch_printf( ch, "Jackpot:         %d\r\n", lottery->jackpot );
            ch_printf( ch, "BaseJackpot:     %d\r\n", lottery->basejackpot );
            ch_printf( ch, "Price:           %d\r\n", lottery->price );
            if( !lottery->raffle )
            {
               ch_printf( ch, "HighNum:         %d\r\n", lottery->high_num );
               ch_printf( ch, "LowNum:          %d\r\n", lottery->low_num );
               ch_printf( ch, "MatchesToWin:    %d\r\n", lottery->matchestowin );
               if( lottery->matchestowin > 0 )
                  ch_printf( ch, "PrizeForMatches: %d\r\n", lottery->prizeformatches );
               ch_printf( ch, "ReuseNumbers:    %s\r\n", lottery->reusenumbers ? "TRUE" : "FALSE" );
               ch_printf( ch, "DrawDiffLast:    %s\r\n", lottery->drawdifflast ? "TRUE" : "FALSE" );
               if( lottery->drawdifflast )
               {
                  ch_printf( ch, "HighLastNum:     %d\r\n", lottery->high_last_num );
                  ch_printf( ch, "LowLastNum:      %d\r\n", lottery->low_last_num );
               }
               ch_printf( ch, "MatchOrder:      %s\r\n", lottery->matchorder ? "TRUE" : "FALSE" );
            }
            ch_printf( ch, "JPercent:        %d\r\n", lottery->jpercent );
            ch_printf( ch, "AutoRedraw:      %s\r\n", lottery->autoredraw ? "TRUE" : "FALSE" );
            ch_printf( ch, "Raffle:          %s\r\n", lottery->raffle ? "TRUE" : "FALSE" );

            for( lhistory = lottery->first_lhistory; lhistory; lhistory = lhistory->next )
            {
               ch_printf( ch, "   Drawn: %s", lhistory->drawn ? "Yes" : "No" );
               if( lhistory->drawn )
                  ch_printf( ch, ", Winning Numbers: %s.", lhistory->winning_numbers ? lhistory->winning_numbers : "" );
               send_to_char( "\r\n", ch );

               buyers = 0;

               for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner->next )
               {
                  buyers++;
               }
               if( !lhistory->drawn )
                  ch_printf( ch, "      Buyers: %d\r\n", buyers );
               else
                  ch_printf( ch, "      Unclaimed Winners: %d\r\n", buyers );
            }
            return;
         }

         claimed = atoi( argument );

         if( !str_cmp( arg, "autoredraw" ) )
         {
            lottery->autoredraw = !lottery->autoredraw;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's autoredraw to %s.\r\n", lottery->autoredraw ? "TRUE" : "FALSE" );
            return;
         }

         if( !str_cmp( arg, "raffle" ) )
         {
            lottery->raffle = !lottery->raffle;

            /* Don't need these if doing a raffle */
            if( lottery->raffle )
            {
               lottery->matchorder = FALSE;
               lottery->drawdifflast = FALSE;
               lottery->reusenumbers = FALSE;
               lottery->matchestowin = 0;
               lottery->prizeformatches = 0;
               lottery->low_last_num = 0;
               lottery->high_last_num = 0;
               lottery->low_num = 0;
               lottery->high_num = 0;
               lottery->numbers = 0;
            }
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's raffle to %s.\r\n", lottery->raffle ? "TRUE" : "FALSE" );
            return;
         }

         if( !str_cmp( arg, "timebetweendraws" ) )
         {
            if( claimed <= 0 )
            {
               send_to_char( "How much time (in seconds) would you like between each drawing for this lottery.\r\n", ch );
               return;
            }
            lottery->timebetweendraws = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's timebetweendraws to %d.\r\n", lottery->timebetweendraws );
            return;
         }

         if( !str_cmp( arg, "drawtime" ) )
         {
            if( claimed <= 0 )
            {
               send_to_char( "How many minutes from now would you like the drawing to be?\r\n", ch );
               return;
            }
            lottery->timetodraw = ( current_time + ( claimed * 60 ) );
            save_lotterys( );
            ch_printf( ch, "You have set the lottery's drawtime to %s.\r\n", distime( lottery->timetodraw ) );
            return;
         }

         if( !str_cmp( arg, "matchorder" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need matchorder on a raffle.\r\n", ch );
               return;
            }
            lottery->matchorder = !lottery->matchorder;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's matchorder to %s.\r\n", lottery->matchorder ? "TRUE" : "FALSE" );
            return;
         }

         if( !str_cmp( arg, "drawdifflast" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need drawdifflast on a raffle.\r\n", ch );
               return;
            }

            lottery->drawdifflast = !lottery->drawdifflast;
            if( lottery->drawdifflast )
            {
               lottery->low_last_num = lottery->low_num;
               lottery->high_last_num = lottery->high_num;
            }
            else
            {
               lottery->low_last_num = 0;
               lottery->high_last_num = 0;
            }
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's drawdifflast to %s.\r\n", lottery->drawdifflast ? "TRUE" : "FALSE" );
            return;
         }

         if( !str_cmp( arg, "reusenumbers" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need reusenumbers on a raffle.\r\n", ch );
               return;
            }

            lottery->reusenumbers = !lottery->reusenumbers;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's reusenumbers to %s.\r\n", lottery->reusenumbers ? "TRUE" : "FALSE" );
            return;
         }

         if( !str_cmp( arg, "matchestowin" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need matchestowin on a raffle.\r\n", ch );
               return;
            }
            if( claimed < 0 )
            {
               send_to_char( "What would you like to set the matchestowin to?\r\n", ch );
               return;
            }
            if( claimed >= lottery->numbers )
            {
               send_to_char( "You can't require the same or more numbers then the lottery uses for lower prizes.\r\n", ch );
               return;
            }
            lottery->matchestowin = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's matchestowin to %d.\r\n", lottery->matchestowin );
            return;
         }

         if( !str_cmp( arg, "jpercent" ) )
         {
            if( claimed <= 0 || claimed > 100 )
            {
               send_to_char( "You have to set jpercent between 1 and 100.\r\n", ch );
               return;
            }
            lottery->jpercent = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's jpercent to %d.\r\n", lottery->jpercent );
            return;
         }

         if( !str_cmp( arg, "prizeformatches" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need prizeformatches on a raffle.\r\n", ch );
               return;
            }
            if( claimed < 0 )
            {
               send_to_char( "What would you like to set the prizeformatches to?\r\n", ch );
               return;
            }
            lottery->prizeformatches = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's prizeformatches to %d.\r\n", lottery->prizeformatches );
            return;
         }

         if( !str_cmp( arg, "lowlastnum" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need lowlastnum on a raffle.\r\n", ch );
               return;
            }
            if( !lottery->drawdifflast )
            {
               send_to_char( "You don't need lowlastnum if drawdifflast isn't true.\r\n", ch );
               return;
            }
            if( claimed < 0 )
            {
               send_to_char( "What would you like to set the lowlastnum to?\r\n", ch );
               return;
            }
            lottery->low_last_num = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's lowlastnum to %d.\r\n", lottery->low_last_num );
            return;
         }

         if( !str_cmp( arg, "highlastnum" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need highlastnum on a raffle.\r\n", ch );
               return;
            }
            if( !lottery->drawdifflast )
            {
               send_to_char( "You don't need highlastnum if drawdifflast isn't true.\r\n", ch );
               return;
            }
            if( claimed < 0 )
            {
               send_to_char( "What would you like to set the highlastnum to?\r\n", ch );
               return;
            }
            lottery->high_last_num = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's highlastnum to %d.\r\n", lottery->high_last_num );
            return;
         }

         if( !str_cmp( arg, "lownum" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need lownum on a raffle.\r\n", ch );
               return;
            }
            if( claimed <= 0 )
            {
               send_to_char( "What would you like to set the lownum to?\r\n", ch );
               return;
            }
            lottery->low_num = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's lownum to %d.\r\n", lottery->low_num );
            return;
         }

         if( !str_cmp( arg, "highnum" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need highnum on a raffle.\r\n", ch );
               return;
            }
            if( claimed <= 0 )
            {
               send_to_char( "What would you like to set the highnum to?\r\n", ch );
               return;
            }
            lottery->high_num = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's highnum to %d.\r\n", lottery->high_num );
            return;
         }

         if( !str_cmp( arg, "price" ) )
         {
            if( claimed <= 0 )
            {
               send_to_char( "What would you like to set the price to?\r\n", ch );
               return;
            }
            lottery->price = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's price to %d.\r\n", lottery->price );
            return;
         }

         if( !str_cmp( arg, "basejackpot" ) )
         {
            if( claimed <= 0 )
            {
               send_to_char( "What would you like to set the basejackpot to?\r\n", ch );
               return;
            }
            lottery->basejackpot = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's basejackpot to %d.\r\n", lottery->basejackpot );
            return;
         }

         if( !str_cmp( arg, "jackpot" ) )
         {
            if( claimed <= 0 )
            {
               send_to_char( "What would you like to set the jackpot to?\r\n", ch );
               return;
            }
            lottery->jackpot = claimed;
            save_lotterys( );
            ch_printf( ch, "You have set that lottery's jackpot to %d.\r\n", lottery->jackpot );
            return;
         }

         if( !str_cmp( arg, "name" ) )
         {
            if( !argument || argument[0] == '\0' )
            {
               send_to_char( "You can't set the name to nothing.\r\n", ch );
               return;
            }
            STRSET( lottery->name, argument );
            save_lotterys( );
            ch_printf( ch, "You set that lottery's name to %s.\r\n", lottery->name );
            return;
         }

         if( !str_cmp( arg, "numbers" ) )
         {
            if( lottery->raffle )
            {
               send_to_char( "You don't need numbers on a raffle.\r\n", ch );
               return;
            }
            if( claimed <= 0 )
            {
               send_to_char( "How many numbers would you like to have in this drawing?\r\n", ch );
               return;
            }
            lottery->numbers = claimed;
            save_lotterys( );
            ch_printf( ch, "You set that lottery's numbers to %d.\r\n", lottery->numbers );
            return;
         }

         send_to_char( "Unknown setting.\r\n", ch );
         return;
      }
   }

   if( !str_cmp( arg, "buy" ) )
   {
      int quickbuys = 1, bought = 0;
      bool quickpicks = FALSE, rafflepicks = FALSE;

      argument = one_argument( argument, arg2 );

      lottery = find_lottery( arg2 );
      if( !lottery )
      {
         send_to_char( "No such lottery to buy a ticket for.\r\n", ch );
         return;
      }

      if( !( lhistory = lottery->last_lhistory ) )
      {
         send_to_char( "No lhistory for you to buy a lottery ticket.\r\n", ch );
         bug( "%s: lhistory NULL.", __FUNCTION__ );
         return;
      }

      if( lhistory->drawn )
      {
         send_to_char( "This one has already been drawn.\r\n", ch );
         return;
      }

      if( !check_lottery( ch, lottery ) )
         return;

      one_argument( argument, arg2 );
      if( lottery->raffle )
      {
         argument = one_argument( argument, arg2 );
         rafflepicks = TRUE;
         if( arg2 != NULL && arg2[0] != '\0' && is_number( arg2 ) )
            quickbuys = atoi( arg2 );
      }
      else if( !str_cmp( arg2, "quickpick" ) )
      {
         argument = one_argument( argument, arg2 );
         quickpicks = TRUE;
         if( argument && argument[0] != '\0' && is_number( argument ) )
            quickbuys = atoi( argument );
      }
      else if( count_nums( argument ) != lottery->numbers )
      {
         ch_printf( ch, "You must enter %d numbers for this lottery.\r\n", lottery->numbers );
         return;
      }
      else if( !can_use_lnums( lottery, argument ) )
      {
         if( lottery->drawdifflast )
            ch_printf( ch, "You must use %snumbers from %d to %d for the first %d numbers and from %d to %d for the last number.\r\n",
               !lottery->reusenumbers ? "different " : "", lottery->low_num, lottery->high_num, ( lottery->numbers - 1 ), lottery->low_last_num, lottery->high_last_num );
         else
            ch_printf( ch, "You must use %snumbers from %d to %d for each of the %d numbers.\r\n",
               !lottery->reusenumbers ? "different " : "", lottery->low_num, lottery->high_num, lottery->numbers );
         return;
      }
      else
      {
         if( lottery->matchorder )
            snprintf( quickpick, sizeof( quickpick ), "%s", argument );
         else
            snprintf( quickpick, sizeof( quickpick ), "%s", sortnums( lottery, argument ) );
      }

      while( quickbuys > 0 )
      {
         if( ch->gold < lottery->price )
         {
            if( bought == 0 )
               ch_printf( ch, "You don't have the %d zeni needed to buy this lottery ticket.\r\n", lottery->price );
            else
            {
               ch_printf( ch, "You only had enough gold to buy %d lottery ticket%s.\r\n", bought, bought == 1 ? "" : "s" );
               save_lotterys( );
            }
            return;
         }

         CREATE( lwinner, LWINNER_DATA, 1 );
         if( !lwinner )
         {
            send_to_char( "No lwinner could be created for you to buy a lottery ticket.\r\n", ch );
            bug( "%s: lwinner NULL after create.", __FUNCTION__ );
            if( bought > 0 )
            {
               ch_printf( ch, "You only managed to buy %d lottery ticket%s.\r\n", bought, bought == 1 ? "" : "s" );
               save_lotterys( );
            }
            return;
         }

         STRSET( lwinner->winner, ch->name );
         if( quickpicks )
         {
            quickpick[0] = '\0';
            snprintf( quickpick, sizeof( quickpick ), "%s", quickpicknums( lottery ) );
         }
         if( rafflepicks )
         {
            quickpick[0] = '0';
            snprintf( quickpick, sizeof( quickpick ), "%d", ++lottery->ticketsbought );
         }
         STRSET( lwinner->used_numbers, quickpick );
         lwinner->winnings = 0;
         LINK( lwinner, lhistory->first_lwinner, lhistory->last_lwinner, next, prev );
         lottery->jackpot += (int)( (double)( ( lottery->price * lottery->jpercent ) / 100 ) );
         decrease_gold( ch, lottery->price);
         quickbuys--;
         bought++;
      }

      ch_printf( ch, "You have just bought %d lottery ticket%s.\r\n", bought, bought == 1 ? "" : "s" );

      save_lotterys( );
      return;
   }

   if( !str_cmp( arg, "claim" ) )
   {
      bool savelottery = FALSE;

      for( lottery = first_lottery; lottery; lottery = lottery->next )
      {
         for( lhistory = lottery->first_lhistory; lhistory; lhistory = lhistory_next )
         {
            lhistory_next = lhistory->next;

            if( !lhistory->drawn )
               continue;

            for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner_next )
            {
               lwinner_next = lwinner->next;

               if( !str_cmp( lwinner->winner, ch->name ) && can_hold_gold( ch, lwinner->winnings ) )
               {
                  increase_gold( ch, lwinner->winnings );
                  claimed++;
                  savelottery = TRUE;
                  UNLINK( lwinner, lhistory->first_lwinner, lhistory->last_lwinner, next, prev );
                  free_lwinner( lwinner );
               }
            }

            if( !lhistory->first_lwinner )
            {
               UNLINK( lhistory, lottery->first_lhistory, lottery->last_lhistory, next, prev );
               free_lhistory( lhistory );
               savelottery = TRUE;
            }
         }
      }

      if( savelottery )
         save_lotterys( );

      if( claimed > 0 )
         ch_printf( ch, "You have claimed %d winning%s.\r\n", claimed, claimed == 1 ? "" : "s" );
      else
         send_to_char( "You don't have any winnings to claim.\r\n", ch );
      return;
   }

 lottery = find_lottery( arg );
 
   if( !lottery )
      do_help( ch, (char *)"lottery" );
   else
   {
      int cnt = 1, maxcnt = 50, oncnt = 0;

      /* If just one arg start at that number and show up to 50 */
      /* Don't allow cnt to be less than 1 */
      argument = one_argument( argument, arg );
      if( arg != NULL && arg[0] != '\0' )
         cnt = UMAX( 0, atoi( arg ) );

      /* If there is another arg adjust the maxcnt */
      /* Don't allow maxcnt to be less than 0 or more than 100 */
      argument = one_argument( argument, arg );
      if( arg != NULL && arg[0] != '\0' )
         maxcnt = URANGE( 0, ( atoi( arg ) - cnt ), 100 );

      for( lhistory = lottery->first_lhistory; lhistory; lhistory = lhistory->next )
      {
         if( lhistory->drawn )
            ch_printf( ch, "Winning numbers: %s.\r\n", lhistory->winning_numbers ? lhistory->winning_numbers : "" );
         else
            ch_printf( ch, "DrawTime         %s\r\n", distime( lottery->timetodraw ) );

         for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner->next )
         {
            if( str_cmp( lwinner->winner, ch->name ) )
               continue;
            ++oncnt;
            if( oncnt < cnt )
               continue;
            if( oncnt == cnt )
               ch_printf( ch, "   Showing tickets %d to %d.\r\n", cnt, ( cnt + maxcnt ) );
            if( maxcnt-- < 0 )
               break;

            ch_printf( ch, "   %3d Numbers: %s ", oncnt, lwinner->used_numbers );
            if( lhistory->drawn && lwinner->winnings > 0 )
               ch_printf( ch, "Winnings: %d", lwinner->winnings );
            send_to_char( "\r\n", ch );
         }
      }
   }
}


It just freezes no crashes no nothing... This is how I have the lottery weekly set up

#LOTTERY
Name             Weekly~
Jackpot          100000
BaseJackpot      100000
TimeToDraw       1378258498
TimeBetweenDraws 604800
Price            1000
Tickets          0
Numbers          6
HighNum          1
LowNum           1
HighLast         50
LowLast          20
Prize4Match      500
JPercent         70
Match2Win        3
AutoRedraw
DrawDiffLast
History     ~ FALSE
End

pretty sure I know the problem is the high a nd low num but just thought it was something I should bring to your attention.

Post is unread #31 Sep 2, 2013 10:04 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Also I did this wrong but this how I have handle_winner looking. It doesn't seem to work on the if no winners at all part for the info message
/* This will handle the winnings after the drawing */
void handle_winnings( LOTTERY_DATA *lottery )
{
   LHISTORY_DATA *lhistory;
   LWINNER_DATA *lwinner, *lwinner_next = NULL;
   int jwinners = 0, jackpot = 0, matchednums;
   char buf[MSL];
   int winners = 0;
   /* The first entry should be the current drawing */
   lhistory = lottery->last_lhistory;

   /* First look for jackpot winners */
   for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner->next )
   {
      if( str_cmp( lhistory->winning_numbers, lwinner->used_numbers ) )
         continue;
      jwinners++;
   }

   /* Now split the jackpot between the winners */
   if( jwinners > 0 )
   {
      jackpot = lottery->jackpot;
      lottery->jackpot = lottery->basejackpot;
      if( jwinners > 1 )
         jackpot /= jwinners;
   }

   /* Ok now we set the winners */
   for( lwinner = lhistory->first_lwinner; lwinner; lwinner = lwinner_next )
   {
      lwinner_next = lwinner->next;

      matchednums = check_winner( lhistory, lwinner );

      /* No matches continue on */
      if( matchednums <= 0 )
      {
         UNLINK( lwinner, lhistory->first_lwinner, lhistory->last_lwinner, next, prev );
         free_lwinner( lwinner );
         continue;
      }

      /* If all match we have a jackpot winner */
      if( matchednums == lottery->numbers )
      {
         lwinner->winnings = jackpot;
		 snprintf( buf, sizeof( buf ), "The jackpot winner is %s.", lwinner->winner );
		 talk_info(AT_WHITE,buf);
		 winners++;

      }
      else if( lottery->matchestowin > 0 && matchednums >= lottery->matchestowin )
      {
         lwinner->winnings = ( ( ( 1 + matchednums ) - lottery->matchestowin ) * lottery->prizeformatches );
		 		 snprintf( buf, sizeof( buf ), "%s has one a smaller amount.", lwinner->winner );
		 talk_info(AT_WHITE,buf);
		 winners++;
      }
      else /* Not enough for any winnings so remove */
      {
         UNLINK( lwinner, lhistory->first_lwinner, lhistory->last_lwinner, next, prev );
         free_lwinner( lwinner );
      }
   }
   if (winners >0 )
   talk_info(AT_WHITE,"A winner was not drawn for this lotto, so the jackpot will continue over");
}

Post is unread #32 Sep 2, 2013 10:29 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Also would you explain how the raffles work and show me how to set up a sample one. I am trying to test that part to see if there is any bugs in it.

Post is unread #33 Sep 2, 2013 10:38 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
this one?
   if (winners >0 )
   talk_info(AT_WHITE,"A winner was not drawn for this lotto, so the jackpot will continue over";);

you have if winners > 0 shouldn't it be == 0?

Sure use lottery create and then lottery set raffle after that adjust the small amount of things it still allows like price etc... and your all set.

I added in LoP for the next release a lottery channel and set it up to avoid the looping from low num and high num being the same as well as announce the jackpot winners and other winners etc... also added in for it to tell them on login if they had winnings and updated the lottery stuff.

Post is unread #34 Sep 2, 2013 10:44 pm   Last edited Sep 2, 2013 10:48 pm by dbna2
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
well I had a raffle set up but it didn't work, Do I still need to set the numbers, and high and low and shit for raffles?

Post is unread #35 Sep 2, 2013 10:52 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
And is there a way to make the lottery system choose someones winning number out of the already bought tickets? just so I can make sure it works like its suppose too

Post is unread #36 Sep 2, 2013 11:05 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
and one last question is does the lottery system limit you on the amount of tickets you can buy and if not should it?

Post is unread #37 Sep 2, 2013 11:12 pm   Last edited Sep 2, 2013 11:18 pm by dbna2
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Also
Ticket Master says, 'Here is your zeni, Thanks for playing.'
The ticketmaster hands you 500 zeni as your prize.
Ticket Master says, 'Here is your zeni, Thanks for playing.'
The ticketmaster hands you 500 zeni as your prize.

I had over 1000 tickets and yeah I can believe that I may have only one on two of them but both only 3 numbers. I am unsure if the doubling thing works. But I might be wrong.

Also is the lotto history suppose to be on there forever? because currently it doesn't have any history even though clearly I won twice two small amounts but twice.
And if your suppose to turn on the history there is no way to do so.

Post is unread #38 Sep 3, 2013 5:03 am   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 

well I had a raffle set up but it didn't work, Do I still need to set the numbers, and high and low and shit for raffles?

You would have to give me the info you have, but if it lets you buy a ticket for it, it should work. nope it doesn't need numbers, high, low, etc... for raffles.


And is there a way to make the lottery system choose someones winning number out of the already bought tickets? just so I can make sure it works like its suppose too

just the raffle system does that


and one last question is does the lottery system limit you on the amount of tickets you can buy and if not should it?

it doesn't, shrug hard call on that


Also
Ticket Master says, 'Here is your zeni, Thanks for playing.'
The ticketmaster hands you 500 zeni as your prize.
Ticket Master says, 'Here is your zeni, Thanks for playing.'
The ticketmaster hands you 500 zeni as your prize.

I had over 1000 tickets and yeah I can believe that I may have only one on two of them but both only 3 numbers. I am unsure if the doubling thing works. But I might be wrong.

Also is the lotto history suppose to be on there forever? because currently it doesn't have any history even though clearly I won twice two small amounts but twice.
And if your suppose to turn on the history there is no way to do so.

Instead of claiming should have looked, It doubles well. There isn't a history claiming clears off you as a winner and if no more winners it clears that drawing info.

Post is unread #39 Sep 4, 2013 6:14 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
suggestion: Make it able to have drawings for other things then money. Like Quest Points I already plan on doing just a thought for u

Post is unread #40 Sep 4, 2013 7:37 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
you could do it for objects too lol

Pages:<< prev 1, 2, 3, 4 next >>