Pessoal como muitos de vocês devem saber nenhum client mobile tem acesso a questões de mira, detectar quem um player estar mirando
Seja esse target um player ou um ator
Eu tentei contornar isso com:
Algumas vezes está detectando, mas muitas vezes está errando, alguém mais experiente poderia me ajudar?
	
	
	
Seja esse target um player ou um ator
Eu tentei contornar isso com:
Código:
public OnPlayerUpdate(playerid)
{
    new playerAim = GetPlayerTargetPlayerEx(playerid);
    if(playerAim != 65535) {
        format(dmgstring, sizeof(dmgstring), "PLAYER AIM PLAYER: [%i]", playerAim);
        SendClientMessage(playerid,COLOR_PARAMEDIC,dmgstring);
        // func
        return true;
    }
    else if(playerAim == 65535) { // else pra só rodar o loop do actor se já não tiver mirando em player
        new actorAim = GetPlayerTargetDynamicActorEx(playerid);
        if(actorAim != 65535)
        {
            format(dmgstring, sizeof(dmgstring), "PLAYER AIM ACTOR: [%i]", actorAim);
            SendClientMessage(playerid,COLOR_PARAMEDIC,dmgstring);
            // func
            return true;
        }
    }
}Código:
forward GetPlayerTargetPlayerEx(playerid);
public GetPlayerTargetPlayerEx(playerid) {
    new x = 65535;
    foreach(new targetid : Player)
    {
        if(IsPlayerFacingPlayer(playerid, targetid, 25.0)) {
            x = targetid;
            return true;
        }
    }
    return x;
}
forward GetPlayerTargetDynamicActorEx(playerid);
public GetPlayerTargetDynamicActorEx(playerid) {
    new x = 65535;
    foreach(new targetid : Actor)
    {
        if(IsPlayerFacingActor(playerid, targetid, 25.0)) {
            x = targetid;
            return true;
        }
    }
    return x;
}
stock static IsAngleInRangeOfAngle(Float:a1, Float:a2, Float:range = 10.0)
{
    a1 -= a2;
    if((a1 < range) && (a1 > -range)) return true;
    return false;
}
stock IsPlayerFacingPlayer(playerid, targetid, Float:range =  10.0)
{
    new Float:pos[3];
    GetPlayerPos(targetid, pos[0], pos[1], pos[2]);
    return IsPlayerFacingPoint(playerid, pos[0], pos[1], range);
}
stock IsPlayerFacingActor(playerid, targetid, Float:range =  10.0)
{
    new Float:pos[3];
    GetDynamicActorPos(targetid, pos[0], pos[1], pos[2]);
    return IsPlayerFacingPoint(playerid, pos[0], pos[1], range);
}
stock IsPlayerFacingPoint(playerid, Float:x, Float:y, Float:range = 10.0)
{
    new Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
 
    new Float:facing;
    GetPlayerFacingAngle(playerid, facing);
 
    new Float:angle;
 
    if( pos[1] > y ) angle = (-acos((pos[0] - x) / floatsqroot((pos[0] - x)*(pos[0] - x) + (pos[1] - y)*(pos[1] - y))) - 90.0);
    else if( pos[1] < y && pos[0] < x ) angle = (acos((pos[0] - x) / floatsqroot((pos[0] - x)*(pos[0] - x) + (pos[1] - y)*(pos[1] - y))) - 450.0);
    else if( pos[1] < y ) angle = (acos((pos[0] - x) / floatsqroot((pos[0] - x)*(pos[0] - x) + (pos[1] - y)*(pos[1] - y))) - 90.0);
 
    return (IsAngleInRangeOfAngle(-angle, facing, range));
}Algumas vezes está detectando, mas muitas vezes está errando, alguém mais experiente poderia me ajudar?

 
	   
	

 

![[Imagem: disc.png]](https://i.ibb.co/YfQpSD1/disc.png) Dimmy#3917
 Dimmy#3917