05.02.2010, 16:27
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
Do you this that
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);
}
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);
}