12.05.2018, 19:23
Hello everyone, how do I make a calculation to check if the angle of the player is facing some coordinate?
@Sorry for the lousy english
@Sorry for the lousy english
IsActorInPlayerFacingAngle(playerid, actorid, Float:max_angle = 90.0, bool:isdynamic = DEFAULT_IS_DYNAMIC_PARAMETER)
{
if(!IsPlayerConnected(playerid) || !AP_IsValidActor(actorid))
return 0;
new Float:ang,
Float:second_ang,
Float:result;
GetPlayerFacingAngle(playerid, ang);
#if USING_STREAMER
if(isdynamic)
GetDynamicActorFacingAngle(actorid, second_ang);
else
GetActorFacingAngle(actorid, second_ang);
#else
#pragma unused isdynamic
GetActorFacingAngle(actorid, second_ang);
#endif
if(ang < 180.0)
result = 180.0 + ang;
else
result = ang - 180.0;
if(second_ang + max_angle > 360.0 || second_ang - max_angle < 0.0)
return ((360.0 - max_angle <= result <= 360.0) || (0.0 <= result <= max_angle));
else
return (second_ang - max_angle <= result <= second_ang + max_angle);
}