Float/Integer problem
#1

I created a labyrinth with random exit. Then i created a textdraw, that shows you a distance from that randomly generated exit using this code:

Код:
publicEx Float:LabyrintFinishDistance(playerid)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	GetPlayerPos(playerid,x1,y1,z1);
	if(labyrintPickupNumber == 0) x2 = 2806.0546,y2 = 2497.5456,z2 = 17.8839;
	else if(labyrintPickupNumber == 1) x2 = 2832.5747,y2 = 2424.4216,z2 = 17.8839;
	else if(labyrintPickupNumber == 2) x2 = 2785.5512,y2 = 2472.7583,z2 = 17.8839;
	else if(labyrintPickupNumber == 3) x2 = 2892.0693,y2 = 2477.0683,z2 = 17.8839;
	else if(labyrintPickupNumber == 4) x2 = 2854.5910,y2 = 2477.0021,z2 = 17.8839;
	else if(labyrintPickupNumber == 5) x2 = 2859.8830,y2 = 2515.4990,z2 = 17.8839;
	else if(labyrintPickupNumber == 6) x2 = 2800.6992,y2 = 2455.8444,z2 = 17.8839;
	else if(labyrintPickupNumber == 7) x2 = 2780.5739,y2 = 2481.6289,z2 = 17.8839;
	return floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
}
But that returning number is f**king long like 1118883351...
Reply
#2

So strange, try using floatround:

pawn Код:
return floatround(floatsqroot(((x2 - x1) * (x2-x1)) + ((y2-y1) * (y2-y1)) + ((z2 - z1) * (z2 - z1))), floatround_round);
Reply
#3

When I use floatround, I get "warning 213: tag mismatch" and I still get those kind of large numbers...
Reply
#4

If u use floatround u must remove
pawn Код:
Float:
here
pawn Код:
publicEx Float:LabyrintFinishDistance(playerid)
or use that
pawn Код:
return floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
but with %.4f
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)