random gives wrong value - 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 gives wrong value (
/showthread.php?tid=643837)
random gives wrong value -
Deadpoop - 28.10.2017
Hi i try to make a money bag event and what i want is to give player random money between 10000-50000
here's my code:
PHP код:
#define MBAG_MAX_PRICE 50000
#define MBAG_MIN_PRICE 10000
new rand = random(MBAG_MIN_PRICE-MBAG_MAX_PRICE)+MBAG_MIN_PRICE;
GivePlayerMoney(playerid, rand);
it does give me random values but not 10000-50000 it gives 199992121 29123313 391882828 values
Re: random gives wrong value -
Konstantinos - 28.10.2017
You need to swap them because you basically call random(-40000) which will return high random values.
Код:
.. random(MBAG_MAX_PRICE-MBAG_MIN_PRICE) ..
Re: random gives wrong value -
Deadpoop - 28.10.2017
Quote:
Originally Posted by Konstantinos
You need to swap them because you basically call random(-40000) which will return high random values.
Код:
.. random(MBAG_MAX_PRICE-MBAG_MIN_PRICE) ..
|
Thnx works!