Check if player is looking at the coordinate? - 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)
+--- Thread: Check if player is looking at the coordinate? (
/showthread.php?tid=653784)
Check if player is looking at the coordinate? -
Paulthaz - 12.05.2018
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
Re: Check if player is looking at the coordinate? -
Gameluner - 12.05.2018
Click
Re: Check if player is looking at the coordinate? -
Dayrion - 12.05.2018
Might this code can help you:
PHP код:
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);
}
Taken from :
https://github.com/Dayrion/actor_plu...nc#L1444-L1473