RANDOM function - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: RANDOM function (
/showthread.php?tid=256860)
RANDOM function -
sciman001 - 22.05.2011
Hi all. I just was playing around with some code and numbers.. and i came up with this. I believe this to be %99.999 truely random. I have NEVER seen it return the same number. I'm NOT even lying! If you dont believe me, test it. Anyway, heres the code for it:
pawn Код:
stock rand()
{
new num=0;
new t, t2, t3;
for(new ct=0; ct<50; ct++)
{
num += ct;
num = random(num * 2);
num -= 4 * 2 / 7;
num += random(num);
num += 5 * ct;
num += random(ct * 5);
for(new dx=0; dx<ct; dx++)
{
if(num < 0)
{
num += 5000;
num *= -2;
num -= random(dx + 50);
if(num > 500000)
{
num -= 10000;
}
}
else if(num > 5000)
{
num += random(5000);
}
gettime(t, t3, t2);
t += t3 - t2;
num += t * 2 - 50;
}
if(num > 500000)
{
num -= 350000;
}
new g, g1, g2;
getdate(g, g1, g2);
g -= g1 + g2;
num += g * 2 - 8 + 6;
}
return num;
}
hehe. Lemme no wut i think! THX!
Re: RANDOM function -
Seven_of_Nine - 22.05.2011
Bullshit.
Ahh joke, it's gud.
EDIT: this is random too:
pawn Код:
new n1,n2,n3,n4,n5;
n1 = random(100);
n2 = random(n1);
n3 = random(n2);
n4 = random(n3);
n5 = random(n4);
return n5;
:P
Re: RANDOM function -
sciman001 - 22.05.2011
well, i updated it. Is the way i test it .. a good way to test it? i am testing right now. i did add a delay of 100 ms so i can c if theres a message of same nums.. but.. idk if im testin it right. i also lowered the number of tests to 1k. Lemme no wut u think now.
Re: RANDOM function -
sciman001 - 22.05.2011
ok..

well, mines more.. cool looking.



p.s. u updated it FOR THE LAST TIME. Please lemme no wut u guys think about it.

THX MAN!
EDIT: UPDATED AGAIN!!!!!!!! AAAAAAAAAAAAAAAAAAAAAAHHHHHHHH!!!!!!!!!!!
Re: RANDOM function -
ddnbb - 22.05.2011
Here you go, most simple random code ever:
pawn Код:
stock Random(min, max){ return min + random(max - min); }