SA-MP Forums Archive
Function to check if a player is facing a point? - 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: Function to check if a player is facing a point? (/showthread.php?tid=125752)



Function to check if a player is facing a point? - Coicatak - 05.02.2010

I know there is the function GetPlayerFacingAngle but it only returns your angle whether you are heading N, S, E, or W.

Is it possible to make a function to check if a player is facing a point with a radi? For example IsPlayerFacingPoint(player, Float, Float:y, Float:radi) which would return true or false?

See my little paint work below.

Thanks in advance.

PS: I've found this by Infierno
pawn Код:
stock GetAngleToXY(Float:X, Float:Y, Float:CurrentX, Float:CurrentY, &Float:Angle)
{
  Angle = atan2(Y-CurrentY, X-CurrentX);
  Angle = floatsub(Angle, 90.0);
  if(Angle < 0.0) Angle = floatadd(Angle, 360.0);
}
Do you this that
pawn Код:
stock IsPlayerFacingPoint(playerid, x, y, radi)
{
  new Float:pX, Float:pY, Float:pZ, Float:Angle, Float:pAngle;
  GetPlayerPos(playerid, pX, pY, pZ);
  GetAngleToXY(x, y, pX, pY, Angle);
  if((pAngle - radi) >= (Angle - radi) && (pAngle + radi) <= (Angle + radi)) return 1;
  return 0;
}

stock GetAngleToXY(Float:X, Float:Y, Float:CurrentX, Float:CurrentY, &Float:Angle)
{
  Angle = atan2(Y-CurrentY, X-CurrentX);
  Angle = floatsub(Angle, 90.0);
  if(Angle < 0.0) Angle = floatadd(Angle, 360.0);
}



Re: Function to check if a player is facing a point? - ¤Adas¤ - 05.02.2010

I have one, but it didnt work perfect yet


Re: Function to check if a player is facing a point? - Nekom - 05.02.2010

See this http://forum.sa-mp.com/index.php?topic=130630.0


Re: Function to check if a player is facing a point? - Coicatak - 05.02.2010

Quote:
Originally Posted by Nekom
Didn't find id. Thanks a lot