SRL Archive - Help and Support

Random extended number


drizzt

2008-03-17 19:27:44

i was thinking about using idletime in my antiban procedure, and the gravity requires an extended variable, so does anyone know how i could find a random extended number?

MylesMadness

2008-03-17 19:34:26

function Rand: Extended;
Returns a random extended value between 0 and 1.

drizzt

2008-03-17 19:35:29

From: Mylesmadness
function Rand: Extended;
Returns a random extended value between 0 and 1.


lol really? stupid question then huh?

MylesMadness

2008-03-17 20:50:23

Theirs no such thing as a stupid question ;)

almost

2008-03-21 11:21:54

I created this for my MoveMouseCircle procedure.
Just adds a little more customization.
//Returns a random extended number between High and Low with Digits amount of digits
function RandomExtended(Low, High, Digits: integer): Extended;
var
Number: string;
i: integer;
begin
Number:= '0.' + FloatToStr(RandomRange(Low, High));
for i:= 1 to (Digits - 1) do
Number:= Number + IntToStr(Random(10));
Result:= StrToFloat(Number);
end;

Wizzup?

2008-03-21 11:29:25

From: almost
I created this for my MoveMouseCircle procedure.
Just adds a little more customization.
//Returns a random extended number between High and Low with Digits amount of digits
function RandomExtended(Low, High, Digits: integer): Extended;
var
Number: string;
i: integer;
begin
Number:= '0.' + FloatToStr(RandomRange(Low, High));
for i:= 1 to (Digits - 1) do
Number:= Number + IntToStr(Random(10));
Result:= StrToFloat(Number);
end;


Don't use Low and High as variable names…

R0b0t1

2008-03-22 16:40:14

Want some lotion for that burn?


But if you want something OVER 1:


RandomIn := Random(60000);
RandomSt := IntToStr(RandomInt);
RandomSt2:= Insert('.', RandomSt, 1); //6.0000
//Insert(..., ..., 2) -> 60.000
RandomEx := StrToFloat(RandomSt2);

That… might work.

mixster

2008-03-22 16:43:24

Or just do Rand * x? Then maybe use my RoundDec to make it a set length :)

almost

2008-03-25 00:10:47

Wizzup
Why not it works fine?

And this procedure is just for a random decimal.
You can do
Random(10) + RandomExtended(0, 9, 5)
and return something like 8.40313

mixster

2008-03-25 03:13:02

It may work fine, but it writes over Scar's Low and High functions (aka LOWest array index with a value (I think, I normally use 0) and HIGHest array index with a value).

R0b0t1

2008-03-25 19:46:27

Damn! Unbelieveable! He just keeps on winning!


I didn't know that variables overwrote functions though… Functions technically have a NAME@NumberOfBytesInArguments thing going on.

almost

2008-03-25 23:28:17

Ah yes i knew that that happens but i don't use the SRL include in the script that has that procedure so it doesn't effect me at all.

mixster

2008-03-26 03:25:21


program New;
var
a: array[0..5] of Integer;
High: Integer;
begin
High := 1;
Writeln(IntToStr(High(a)));
end.
High is a Scar function, not a SRL one - uncomment the High := 1 and var declaration for it and you'll see it work :)

nielsie95

2008-03-26 10:54:42

No function gets an override.


program New;

procedure HelloThere(High, Low: Integer);
begin
WriteLn('High = '+IntToStr(High)+', Low = '+IntToStr(Low));
end;

var
a: TIntegerArray;
begin
SetLength(a, 2);
WriteLn('High a: '+IntToStr(High(a)));
HelloThere(High(a), Low(a));
end.

It get does get an override when you call a function or procedure like it:


program New;

function High(a: variant): Integer;
begin
Result := 100;
end;

procedure HelloThere(High, Low: Integer);
begin
WriteLn('High = '+IntToStr(High)+', Low = '+IntToStr(Low));
end;

var
a: TIntegerArray;
begin
SetLength(a, 2);
WriteLn('High a: '+IntToStr(High(a)));
HelloThere(High(a), Low(a));
end.

the scar noob

2008-03-26 12:47:49

From: drizzt
i was thinking about using idletime in my antiban procedure, and the gravity requires an extended variable, so does anyone know how i could find a random extended number?


Don't care about it, random even doesn't excists:p

-Tsn.

EDIT: And if you might care, try this:

function RandomExtended(Range: Extended): Extended;
begin
Result := Range*Rand;
end;