Setting random amount (Min-Max)
#9

Alright, let's suppose that you pass 100 and 250 to the function. What you would end up with (internally) is this:
pawn Код:
return 100 + random(250 - 100)
Which in turn gets simplified to
pawn Код:
return 100 + random(150)
Now, as you know the random function now returns a random value between 0 and 150. Let's suppose the random value is 0. The 100 from before gets added and 100 is returned. Let's suppose the random value is 149. Again, the 100 from before gets added and 249 is returned.

Usage is just the same as the regular random function.

pawn Код:
new randomNumber = minrandom(100, 250);
Reply


Messages In This Thread
Setting random amount (Min-Max) - by weedxd - 02.10.2014, 10:36
Re : Setting random amount (Min-Max) - by AmirRFCNR - 02.10.2014, 10:47
Re: Setting random amount (Min-Max) - by weedxd - 02.10.2014, 10:58
Re: Re : Setting random amount (Min-Max) - by Vince - 02.10.2014, 11:06
Re: Setting random amount (Min-Max) - by PMH - 02.10.2014, 11:08
Re: Re : Setting random amount (Min-Max) - by weedxd - 02.10.2014, 11:09
Re: Setting random amount (Min-Max) - by weedxd - 02.10.2014, 11:11
Re : Re: Setting random amount (Min-Max) - by AmirRFCNR - 02.10.2014, 11:27
Re: Setting random amount (Min-Max) - by Vince - 02.10.2014, 11:30
Re: Setting random amount (Min-Max) - by weedxd - 02.10.2014, 11:32

Forum Jump:


Users browsing this thread: 4 Guest(s)