Calculating player's distance from a specific location. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Calculating player's distance from a specific location. (
/showthread.php?tid=261130)
Calculating player's distance from a specific location. -
Emre__ - 12.06.2011
Hi people,
I want to calculate a player's distance from a given location. For example:
pawn Код:
187.124574, -1547.457456, 51.245541 //Player's position
1547.651242, 514.515450, 50.541244 // The point the I want to calculate how far this from players position.
And how do I convert this variable to mile, meter or anything I want.
Re: Calculating player's distance from a specific location. -
Vince - 12.06.2011
As far as I know, GTA SA uses the metric system for distances. The height of an average ped in SA is 1.9, which is also the average height of a normal person in meters.
pawn Код:
stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
x1 -= x2;
y1 -= y2;
z1 -= z2;
return floatsqroot((x1 * x1) + (y1 * y1) + (z1 * z1));
}