05.12.2010, 10:58
Does anyone know a function to generate a random float? I need it to work just like random() but for floats.
I\'ve made one myself, but using format() for stuff like this is not very good. This works, by the way:
I\'ve made one myself, but using format() for stuff like this is not very good. This works, by the way:
Code:
stock randomfloat(Float:max) { new bob[32], floats[2][16]; format(bob, 32, \"%0.1f\", max); split(bob, floats, \'.\'); format(bob, 32, \"%d.%d\",random(strval(floats[0])), random(strval(floats[1]))); return _:floatstr(bob); }