SRL Archive - Other Scripts

Lottery Numbers Generator


Janilabo

2009-07-11 21:56:28

I made this to generate numbers to lottery… :)

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. :mad:
[/LOL!]

Da 0wner

2009-07-11 22:06:54

InIntArray is already a function…?

Janilabo

2009-07-11 22:16:55

From: Da 0wner
InIntArray is already a function…?
Mate, it's not in SCAR's functions.. I think you are getting it from SRL. :p

Or from a Plugin

Da 0wner

2009-07-11 22:19:07

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

caused

2009-07-11 22:21:33

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

Janilabo

2009-07-11 22:24:46

That's a promise, right? :D

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