random between two float numbers Tag mismatch - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: random between two float numbers Tag mismatch (
/showthread.php?tid=556294)
random between two float numbers Tag mismatch -
DiamantEspace18 - 10.01.2015
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
Re: random between two float numbers Tag mismatch -
Misiur - 10.01.2015
Random expects tagless value. Use floatround on max-min.
Re : random between two float numbers Tag mismatch -
DiamantEspace18 - 10.01.2015
Okay but how I do it ? 'Cause I don't understand how floatround works
Re: random between two float numbers Tag mismatch -
Gammix - 10.01.2015
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!
Re: random between two float numbers Tag mismatch -
Misiur - 10.01.2015
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;
Re : random between two float numbers Tag mismatch -
DiamantEspace18 - 10.01.2015
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