PlayerLookingAt?
#2

pawn Код:
stock GetPlayerCameraFacingAngle(playerid, &Float:Angle)
{
        new Float:X, Float:Y;
    new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
    new Float:XP,Float:YP,Float:ZP;
    if(!IsPlayerInAnyVehicle(playerid))
    {
                GetPlayerPos(playerid,XP ,YP ,ZP);
            GetPlayerCameraPos(playerid, cx, cy, cz);
            GetPlayerCameraFrontVector(playerid, fx, fy, fz);
            X = fx * 999 + cx;
            Y = fy * 999 + cy;
                if(Y > YP) Angle = (-acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
                if(Y < YP && X < XP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP))) - 450.0);
                else if(Y < YP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
                if(X > XP) Angle = (floatabs(floatabs(Angle) + 180.0));
                else Angle = (floatabs(Angle) - 180.0);
        }
        else if(IsPlayerInAnyVehicle(playerid))
    {
                GetVehiclePos(GetPlayerVehicleID(playerid),XP ,YP ,ZP);
            GetPlayerCameraPos(playerid, cx, cy, cz);
            GetPlayerCameraFrontVector(playerid, fx, fy, fz);
            X = fx * 999 + cx;
            Y = fy * 999 + cy;
                if(Y > YP) Angle = (-acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
                if(Y < YP && X < XP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP))) - 450.0);
                else if(Y < YP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
                if(X > XP) Angle = (floatabs(floatabs(Angle) + 180.0));
                else Angle = (floatabs(Angle) - 180.0);
        }
}
Try this. Not tested
Reply


Messages In This Thread
PlayerLookingAt? - by Meisternuke - 08.10.2014, 01:12
Re: PlayerLookingAt? - by Josh_Main - 08.10.2014, 01:15
Re: PlayerLookingAt? - by Meisternuke - 13.10.2014, 01:18
Re: PlayerLookingAt? - by Abagail - 13.10.2014, 01:40

Forum Jump:


Users browsing this thread: 1 Guest(s)