Random
#6

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
Reply


Messages In This Thread
Random - by TheNavigator - 13.10.2011, 20:54
Re: Random - by JiHost - 13.10.2011, 20:56
Re: Random - by Wesley221 - 13.10.2011, 20:57
Re: Random - by AeroBlast - 13.10.2011, 20:57
Re: Random - by TheNavigator - 13.10.2011, 21:27
Re: Random - by grand.Theft.Otto - 13.10.2011, 22:04
Re: Random - by TheNavigator - 14.10.2011, 08:06

Forum Jump:


Users browsing this thread: 1 Guest(s)