08.02.2015, 15:17
Hello !
How to make a random float?
Between 0.50 and 2.15 for example.
++
How to make a random float?
Between 0.50 and 2.15 for example.
++
new n1 = random(10000); //or whatever should be the max value infront of the .
new n2 = random(10000); //number behind the .
new string[50];
format(string, sizeof(string), "%d.%d", n1, n2);
new Float:randomfloat = floatstr(string);
e.g. like this: no clue if there is a better solution
pawn Код:
|
new n1 = random(3); //or whatever should be the max value infront of the .
new n2;
if(n1 == 0)
n2 = random(50) + 50;
else if(n1 == 2)
n2 = random(16);
else
n2 = random(100);
new string[50];
format(string, sizeof(string), "%d.%d", n1, n2);
new Float:randomfloat = floatstr(string);