random gives wrong value
#1

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(playeridrand); 
it does give me random values but not 10000-50000 it gives 199992121 29123313 391882828 values
Reply
#2

You need to swap them because you basically call random(-40000) which will return high random values.
Код:
.. random(MBAG_MAX_PRICE-MBAG_MIN_PRICE) ..
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)