Function to check if a player is facing a point?
#1

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);
}
Reply
#2

I have one, but it didnt work perfect yet
Reply
#3

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)