Random - 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)
+--- Thread: Random (
/showthread.php?tid=290014)
Random -
TheNavigator - 13.10.2011
What was the code responsible for picking up a random number between numbers?
Re: Random -
JiHost - 13.10.2011
Search forum. This was answered billion times.
Re: Random -
Wesley221 - 13.10.2011
random()
pawn Код:
new RandomNumber = random(500);
print( RandomNumber );
That will print a number between 0-500
Re: Random -
AeroBlast - 13.10.2011
random(number);
Ex:
pawn Код:
rand = random(3);
switch(rand)
{
case 0: Blah Blah;
case 1: Blah Blah;
case 2: Blah Blah;
}
EDIT: I'm tad late...
Re: Random -
TheNavigator - 13.10.2011
Quote:
Originally Posted by Wesley221
random()
pawn Код:
new RandomNumber = random(500); print( RandomNumber );
That will print a number between 0-500
|
Wrong. 0-499
Thanks for your help guys anyway
I searched and it said Rand at some places, so I wanted to make sure
Re: Random -
grand.Theft.Otto - 13.10.2011
If you want to get numbers between a certain x digit and a certain y digit, you can add this to the bottom of your script:
pawn Код:
// credit to KyleSmith
stock randomEx(minnum = cellmin, maxnum = cellmax)
{
return random(maxnum - minnum + 1) + minnum;
}
Then use it to get random lotto numbers for example:
pawn Код:
new lotto = randomEx(1,100); // will pick a random number between 1 and 100
Or for a simple cash payout, between 10,000 and 20,000:
pawn Код:
new payout = randomEx(10000,20000); // will choose a random amount between 10k to 20k
GivePlayerMoney(playerid,payout); // give the player the random cash payout
print(payout); // print the random cash payout
Re: Random -
TheNavigator - 14.10.2011
I already know that
I'll tell you something. I started scripting just few weeks ago, but it seems very easy for me
The main reason is that I know C
Thanks for everyone for help anyway