01.11.2011, 23:09
How do I use GetPlayerDistanceFromPoint in RC3? Apart from using RC4/5....
stock Float:GetPlayerDistanceFromPoint(playerid, Float:X, Float:Y, Float:Z)
{
new Float:pPos[3];
GetPlayerPos(playerid);
return floatsqroot(floatpower(floatsub(X, pPos[0]), 2.0) + floatpower(floatsub(Y, pPos[1]), 2.0) + floatpower(floatsub(Z, pPos[2]), 2.0));
}
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;
}
new Float:distance = GetPlayerDistanceFromPoint(playerid, Xcoord, Ycoord, Zcoord);
pawn Код:
|