random between two float numbers Tag mismatch
#1

Yo everyone , I search how to repair this :

Код:
stock Float:randomEx(Float:min, Float:max)
{
    new Float:rand = float(random(max-min)/10000)+min;//Tag mismatch at this line
    return rand;
}
Thanks for the future help
Reply
#2

Random expects tagless value. Use floatround on max-min.
Reply
#3

Okay but how I do it ? 'Cause I don't understand how floatround works
Reply
#4

pawn Код:
stock Float:randomEx(Float:min, Float:max)
{
    new f_min = floatround(min);
    new f_max = floatround(max);
    new Float:rand = float( random( (f_max - f_min) / 10000 )) + min;
    return rand;
}
You haven't used floatround as Misiur said! But here is the code!
Reply
#5

It's a function. Also float(int / int) in pawn will return closest integer, not a float as you'd expect, so change at least one number to float.

pawn Код:
new Float:rand = random(floatround(max-min)) / 10000.0 + min;
Reply
#6

Okay thanks

But now when i'm teleporting with this :
Код:
                new Float:x = randomEx(-2786.5884,2918.8494);
		new	Float:y = randomEx(-2906.1553,2906.4521);
		new	Float:z = randomEx(564.1456,637.7349);
		SetPlayerPos(playerid,x,y,z);
I've a huge lag and something with bounds
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)