public IsPlayerLookAt(playerid,Float:range,Float:x,Float:y,Float:z)
{
if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))
{
new Float:Face;
GetPlayerFacingAngle(playerid,Face);
return floatsqroot(...
}
}
public IsPlayerLookAt(playerid,Float:range,Float:x,Float:y,Float:z)
{
if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))
{
new Float:Face,Float:FaceX,Float:FaceY,Float:FaceZ;
GetPlayerPos(playerid,FaceX,FaceY,FaceZ);
GetPlayerFacingAngle(playerid,Face);
if(FaceX > 0 && FaceY > 0) { if(Face > -1 && Face < 91) { return 1; } }
if(FaceX < 0 && FaceY > 0) { if(Face > 89 && Face < 181) { return 1; } }
if(FaceX < 0 && FaceY < 0) { if(Face > 179 && Face < 271) { return 1; } }
if(FaceX > 0 && FaceY < 0) { if(Face > 269 && Face < -1) { return 1; } }
}
return 0;
}
public IsPlayerLookAt(playerid, Float:range, Float:x, Float:y, Float:z, Float:max_al, Float:max_ar)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, range, x, y, z))
{
// max_al = max angle left
// max_ar = max angle right
// max_al && max_ar coordinates at the top
new Float:angle;
GetPlayerFacing(i, angle);
if(angle > max_al && angle < max_ar) return 1;
else return 0;
}
else return 0;
}
return 0;
}
public IsPlayerLookAt(playerid, const Float:range,
const Float:x, const Float:y, const Float:z, const Float:max_al, const Float:max_ar)
{
if(IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
new Float:angle, Float:Pos[3];
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
if(Pos[0] > x) angle -= (atan( (Pos[1] - y) / (Pos[0] - x) ) + 90.0);
else angle -= (atan( (Pos[1] - y) / (Pos[0] - x) ) + 270.0);
if(angle < 0) {
if((angle > -max_al) || ((angle + 360.0) < max_ar)) return 1;
} else {
if((angle < max_ar) || ((angle - 360.0) > -mal_al)) return 1;
}
}
return 0;
}
Not tested but actually I thought that there were already an include with such functions released |