random numbers bug or? - 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 numbers bug or? (
/showthread.php?tid=598898)
random numbers bug or? -
Lirbo - 18.01.2016
PHP код:
CMD:test(playerid,params[]){
new result = random(15-5)+5*-1;
format(String,sizeof(String),"Result = %i",result);
MSG(playerid,-1,String);
return 1;}
I want it to gimme random number between -5 to -15, why it's giving me sometimes numbers above -5 (means like -3 or even postive numbers such as 4 etc)
Re: random numbers bug or? -
Trucido - 18.01.2016
new randomNumber = random(max-min)+min;
Re: random numbers bug or? -
Lirbo - 18.01.2016
Quote:
Originally Posted by Trucido
new randomNumber = random(max-min)+min;
|
bro... that would give me a postive number between 5 to 15, i want -5 to -15
Re: random numbers bug or? -
PrO.GameR - 18.01.2016
new result = random(15-5)+5*-1 = random(10)-5
Learn the math priorities. a fix would be simply -random(15-5)-5;
Re: random numbers bug or? -
Lirbo - 18.01.2016
Quote:
Originally Posted by PrO.GameR
new result = random(15-5)+5*-1 = random(10)-5
Learn the math priorities. a fix would be simply -random(15-5)-5;
|
hehe ye i thought about random((15-5)-5)*1 etc but it gave me some bugs, thank you