11.08.2009, 16:43
Guys i forget, where i can get Player to point function ? can someone give a link or post it here please
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { if(IsPlayerConnected(playerid)) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return true; } } return false; }
Float:DistFromPlayerToPoint(playerid,Float:X,Float:Y,Float:Z) //Slower, but gives you the distance
{
new Float:tmpx,Float:tmpy,Float:tmpz;
GetPlayerPos(playerid,tmpx,tmpy,tmpz);
return floatsqroot(floatpower(X-tmpx,2)+floatpower(Y-tmpy,2)+floatpower(Z-tmpz,2));
}
IsPlayerNearPoint(playerid,Float:X,Float:Y,Float:Z,Float:radius) //Faster to compute
{
new Float:tmpx,Float:tmpy,Float:tmpz;
GetPlayerPos(playerid,tmpx,tmpy,tmpz);
return ((X-tmpx)*(X-tmpx))+((Y-tmpy)*(Y-tmpy))+((Z-tmpz)*(Z-tmpz))<(radius*radius);
}