Random Money - 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 Money (
/showthread.php?tid=656836)
Random Money -
Dawkin - 25.07.2018
Код:
new money;
money= random(500 to 1000);
I want money random from 500 to 1000
How to do that
Re: Random Money -
coool - 25.07.2018
Use this function
PHP код:
randomex(min, max)
{
return random(max-min)+min;
}
Re: Random Money -
denNorske - 25.07.2018
A better way to explain how you solve it, is to look at the problem part for part.
You want the ranom to start at 500, and end at 1000. Between 500 and 100 you have 500 units.
PHP код:
new money = 500; //This will make it "always" start at 500
money = money + random(500); //then, reinitialize the variable. Tell the script that you want 500 + '0-500' more.
If you want another range, lets say you want a random value between 75-94?
PHP код:
new money = 75;
money = money + random(19); //this will always be 75-94.
This is also basically what the function posted by "Coool" above does, but in a shorter format. I just thought you wanted to know why it worked.
Re: Random Money -
Dawkin - 25.07.2018
Quote:
Originally Posted by denNorske
A better way to explain how you solve it, is to look at the problem part for part.
You want the ranom to start at 500, and end at 1000. Between 500 and 100 you have 500 units.
PHP код:
new money = 500; //This will make it "always" start at 500
money = money + random(500); //then, reinitialize the variable. Tell the script that you want 500 + '0-500' more.
If you want another range, lets say you want a random value between 75-94?
PHP код:
new money = 75;
money = money + random(19); //this will always be 75-94.
This is also basically what the function posted by "Coool" above does, but in a shorter format. I just thought you wanted to know why it worked.
|
Thank you very much, Solved. <3