Player to point
#1

Guys i forget, where i can get Player to point function ? can someone give a link or post it here please
Reply
#2

Код:
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;
}
cheerz
Reply
#3

That one sucks and is inaccurate.

pawn Код:
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);
}
EDIT* Windows 7 messed up my post pretty bad lol, *cleaned*
Reply
#4

ty but 1 more problem , how i can check if the player is at checkpoint ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)