get distance between two points. - 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: get distance between two points. (
/showthread.php?tid=455090)
get distance between two points. -
audriuxxx - 31.07.2013
Hi,
How to get distance between two coordinates?
Ex:
Код:
945.544,489.54,45.164
2015.554,1103.10.98
AW: get distance between two points. -
CutX - 31.07.2013
try that, didnt test but it should work. calculating distances is a big deal. Only do if you really have to and there's no other way 'round it.
Код:
stock Float:GetDistance(Float:x1,Float:y1,Float:z1, Float:x2,Float:y2,Float:z2)
{
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
you could use it like
Код:
new s[13];
format(s, sizeof s,"Distance: %f",GetDistance(945.544,489.54,45.164,2015.554,1103.10.98,45.2));
SendClientMessage(playerid,-1,s);