Results 1 to 6 of 6

Thread: Lottery Numbers Generator

  1. #1
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default Lottery Numbers Generator

    I made this to generate numbers to lottery...

    SCAR Code:
    const
      count = 7;
      minimum = 1;
      maximum = 39;

    var
      lottoNumbers: array[minimum..maximum] of Integer;
      i, i2: Integer;
      s: string;
      myNumbers: TIntegerArray;

    function inIntArr(intArr: TIntegerArray; x: Integer): Boolean;
    var
      i: Integer;
    begin
      for i:= 0 to High(intArr) do
        if(x = intArr[i])then
        begin
          Result:= True;
          Exit;
        end;
    end;

    procedure generateNumbers(var intArr: TIntegerArray);
    var
      i, i2: Integer;
    begin
      SetArrayLength(intArr, count);
      for i:= 0 to (count - 1) do
        intArr[i]:= -1;
      repeat
        i:= lottoNumbers[Random(maximum) + minimum];
        if(not(inIntArr(intArr, i)))then
        begin
          intArr[i2]:= i;
          Inc(i2);
        end;
      until(i2 >= count);
      QuickSort(intArr);
    end;

    begin
      ClearDebug;
      if((maximum - minimum) < (count - 1))then
      begin
        WriteLn('fail.');
        TerminateScript;
      end;
      for i:= minimum to maximum do
        lottoNumbers[i]:= i;
      generateNumbers(myNumbers);
      s:= '[WINNING] Lottery Numbers: ';
      for i:= 0 to (count - 1) do
      begin
        if(i < count)then
          for i2:= 0 to 10 do
          begin
            ClearDebug;
            WriteLn(s + IntToStr(Random(maximum) + 1));
            Wait(100);
          end;
        if(i < (count - 1))then
          s:= s + IntToStr(myNumbers[i]) + ', '
        else
          s:= s + IntToStr(myNumbers[i]);
      end;
      ClearDebug;
      WriteLn(s + '!');
    end.
    [LOL!]
    But but, as I haven't got any millions with it, I have came to a conclusion, that there must be somekind of a scripting error in it!
    Now, please do point me out, incase you track down that problematic part.
    [/LOL!]
    Last edited by Janilabo; 07-12-2009 at 02:03 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    InIntArray is already a function...?

  3. #3
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    InIntArray is already a function...?
    Mate, it's not in SCAR's functions.. I think you are getting it from SRL.

    Or from a Plugin

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe a plugin from SRL o_O. But it's not in the SRL Include (SCAR files).

  5. #5
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    And if I win, you get 50%, eh ?

  6. #6
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    That's a promise, right?

    It definitely is! Good luck, but remember that problematic part, it needs to be fixed first, lol.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •