01.11.2011, 23:40
lol depends on how you define it..
if you do it like this:
(not sure if this function is correct, just wrote it for this purpose)
Then you need to use it in code like this:
if you do it like this:
pawn Код:
stock GetPlayerDistanceFromPoint(playerid, Float:x, Float:y, Float:z)
stock GetPlayerDistanceFromPoint(playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:rst, Float:Coords[3];
GetPlayerPos(playerid, Coords[0], Coords[1], Coords[2]);
Coords[0] = floatabs(Coords[0]) - x;
Coords[1] = floatabs(Coords[1]) - y;
Coords[2] = floatabs(Coords[2]) - z;
rst = floatsqroot((Coords[0] * Coords[0]) + (Coords[1] * Coords[1]) + (Coords[2] * Coords[2]));
return rst;
}
return 0;
}
Then you need to use it in code like this:
pawn Код:
new Float:distance = GetPlayerDistanceFromPoint(playerid, Xcoord, Ycoord, Zcoord);