floatadd - error - 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: floatadd - error (
/showthread.php?tid=622519)
floatadd - error -
skaTim - 23.11.2016
pawn Код:
stock GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
}
when I complile I get the following error:
pawn Код:
./assets/functions.pwn(5443) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
Header size: 18780 bytes
Code size: 1308364 bytes
Data size: 110316400 bytes
Stack/heap size: 16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:111659928 bytes
1 Warning.
Line 5443
pawn Код:
floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
This used to work before..
Re: floatadd - error -
Konstantinos - 23.11.2016
https://sampwiki.blast.hk/wiki/VectorSize
Re: floatadd - error -
AbyssMorgan - 23.11.2016
PHP код:
#define GetDistanceBetweenPoints(%1,%2,%3,%4,%5,%6) VectorSize((%1)-(%4),(%2)-(%5),(%3)-(%6))
Re: floatadd - error -
Vince - 23.11.2016
Quote:
Originally Posted by skaTim
pawn Код:
floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
|
Everyone keeps copying this, but apparently no-one seems to question why the original author bothered using the functions instead of the normal operators. You can't really get around floatsqroot because there isn't an operator for that, but that line is essentially this:
Код:
floatsqroot((x1 - x2) * (x1 - x2)) + floatsqroot((y1 - y2) * (y1 - y2)) + floatsqroot((z1 - z2) * (z1 - z2))
Which, IMO, makes it much more obvious what is going on. VectorSize is currently the fastest, though.