random(!!)
#1

How to make random(between $100k and $300k)
Reply
#2

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!
Reply
#3

pawn Код:
new value = random(max - min) + min;
Reply
#4

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 ?
Reply
#5

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.
Reply
#6

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
Reply
#7

thanks both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)