Random Float Number
#1

Hi, how i can get a float number from random? Like random(1) to get 0.52.
Reply
#2

https://forum.sa-mp.com/showpost.php...52&postcount=3
Reply
#3

https://sampwiki.blast.hk/wiki/Floatround
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
There's a much better version in y_utils. The one in that post takes `(max, min)` as parameters, which makes no sense. The one in y_utils either takes `(max)` or `(min, max)`:

https://github.com/pawn-lang/YSI-Inc....inc#L421-L454
Thank you!

EDIT: I need a little help again.. how i can extract an integer from float? Floatround over 0.50 rounded to a value of 1, it's possible to make if i have a value of 0.99, the integer number to be 0?
Reply
#5

Just check the wiki: https://sampwiki.blast.hk/wiki/Floatround

There you see, that you have diffrent rounding Methods: https://sampwiki.blast.hk/wiki/Floatround_method

For example:

PHP код:
floatround(0.99floatround_floor); //returns 0 
Reply
#6

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Just check the wiki: https://sampwiki.blast.hk/wiki/Floatround

There you see, that you have diffrent rounding Methods: https://sampwiki.blast.hk/wiki/Floatround_method

For example:

PHP код:
floatround(0.99floatround_floor); //returns 0 
I want to return a value from a variable, for example x = 0.99, or x = 0.12, or x = 0.51, you understand now? And x in this case to be 0.
Reply
#7

Yes dude, i understood that.

But it seems, you dont understand the use of a function, so read some basics: https://sampwiki.blast.hk/wiki/Scripting_Basics

You just have to write:

PHP код:
floatround(xfloatround_floor); 
Reply
#8

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Yes dude, i understood that.

But it seems, you dont understand the use of a function, so read some basics: https://sampwiki.blast.hk/wiki/Scripting_Basics

You just have to write:

PHP код:
floatround(xfloatround_floor); 
Yeah it was my bad and thank you! I apologize again man.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)