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=468529)
random(!!) -
AnonScripter - 08.10.2013
How to make random(between $100k and $300k)
Re: random(!!) -
jakejohnsonusa - 08.10.2013
pawn Код:
new rand = random(300000);
if(rand < 100000)
{
rand += 100000;//Makes it stay above 100000
}
//The variable rand now holds a random value between 100k and 300k.
//You can now do do somthing like: GivePlayerMoney(playerid, rand);
Hope that helps!
Re: random(!!) -
Jefff - 08.10.2013
pawn Код:
new value = random(max - min) + min;
Re: random(!!) -
AnonScripter - 08.10.2013
Quote:
Originally Posted by jakejohnsonusa
pawn Код:
new rand = random(300000); if(rand < 100000) { rand += 100000;//Makes it stay above 100000 } //The variable rand now holds a random value between 100k and 300k. //You can now do do somthing like: GivePlayerMoney(playerid, rand);
Hope that helps! 
|
well its nice, but how to use this with rob command
if target money > 1m
giveplayermoney(playerid,random between 100k to 300k)
i made all the code, but how to use ur method in random with this thing.
Quote:
Originally Posted by Jefff
pawn Код:
new value = random(max - min) + min;
|
explain please, where to put it and how to use it ?
Re: random(!!) -
jakejohnsonusa - 08.10.2013
I gave it to you in the post, but you must not have seen it.
Just add this:
pawn Код:
new rand = random(300000);//Creates random number 0-300000.
if(rand < 100000)
{
rand += 100000;//Ensure the random number stay's above 100000.
}
GivePlayerMoney(playerid, rand);//Gives the player the random ammount of money.
Re: random(!!) -
Jefff - 08.10.2013
Replace max to 300000 and min to 100000 or put that define on top in your game mode
pawn Код:
#define random_moneys(%0,%1) (random(%1 - %0) + %0)
Example
pawn Код:
GivePlayerMoney(playerid, random_moneys(100000, 300000)); // MinCash, MaxCash
Re: random(!!) -
AnonScripter - 08.10.2013
thanks both