PlayerLookingAt?
#1

How can i define where the Player is currently looking?

I want to make a antimod sa filterscript.
I freeze the player and if he have mod sa installed his head will look downwards.

So how can i check where the Player is looking?
Reply
#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
#3

hello.. how do i now test with this iff the player is facing left / downwards?
Reply
#4

This is done by freezing the player when they spawn, - and getting their camera vectors and then comparing them upon completion. This doesn't always work and I believe it's best used after they connect/while they(are) spawn(ing).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)