SA-MP Forums Archive
distance from player pos - 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: distance from player pos (/showthread.php?tid=592623)



distance from player pos - fuckingcruse - 27.10.2015

Like I am getting player pos x y and z.. I want to know how can I get players distance from that point after he reaches 1km ingame.. like after he reaches -100$ .. as soon as 1km up -$100.. how can I do it?


Re: distance from player pos - Mellnik - 27.10.2015

https://en.wikipedia.org/wiki/Distance#Geometry

Quote:

In 2D
Define your two points. Point 1 at (x1, y1) and Point 2 at (x2, y2).

xd = x2-x1
yd = y2-y1
Distance = SquareRoot(xd*xd + yd*yd)

In 3D
Define your two points. Point 1 at (x1, y1, z1) and Point 2 at (x2, y2, z2).

xd = x2-x1
yd = y2-y1
zd = z2-z1
Distance = SquareRoot(xd*xd + yd*yd + zd*zd)

Source: http://freespace.virgin.net/hugo.eli...nes/r_dist.htm

https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint

Код:
Float:GetDistance3D(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
	return VectorSize(x1 - x2, y1 - y2, z1 - z2);
}
Did you sleep at school?


Re: distance from player pos - rinori - 27.10.2015

Quote:

Scripting for money , except Mysql and textdraws , I can script everything.

A very ironic signature.


Re: distance from player pos - fuckingcruse - 28.10.2015

Still didn't got The thing I need.