12.06.2018, 14:54
That doesn't look very correct though. Even if it does work, it will not be a true randomized float (it will not be precise).
If you want a real random float you can do that by calculating a random integer between 0 and 1000, convert that number to float and divide it by 1000.0. You'll have a float from 0.0 to 0.999 and can use this as factor for the range you want to randomize.
For example, if you want a random float ranging from 0.0 to a given number (like random(), just as float):
Then you can use this function to calculate a true random float.
If you want a real random float you can do that by calculating a random integer between 0 and 1000, convert that number to float and divide it by 1000.0. You'll have a float from 0.0 to 0.999 and can use this as factor for the range you want to randomize.
For example, if you want a random float ranging from 0.0 to a given number (like random(), just as float):
Код:
forward Float:floatrandom(Float:val);
Float:floatrandom(Float:val)
{
return float(random(1000)) / 1000.0 * val;
}

