IsPlayerLookingAtPlayer problem
#2

This may help:

pawn Код:
stock SetPlayerFacePlayer(playerid, faceplayerid)
{
    new Float:Px, Float:Py, Float: Pa;
    GetPlayerPos(playerid, Px, Py, Pa);
    new Float:fpX, Float:fpY, Float: fpZ;
    GetPlayerPos(faceplayerid, fpX, fpY, fpZ);
    Pa = floatabs(atan((fpY-Py)/(fpX-Px)));
    if(fpX <= Px && fpY >= Py) Pa = floatsub(180, Pa);
    else if(fpX < Px && fpY < Py) Pa = floatadd(Pa, 180);
    else if(fpX >= Px && fpY <= Py) Pa = floatsub(360.0, Pa);
    Pa = floatsub(Pa, 90.0);
    if(Pa >= 360.0) Pa = floatsub(Pa, 360.0);
    if(!IsPlayerInAnyVehicle(playerid)) SetPlayerFacingAngle(playerid, Pa);
    else SetVehicleZAngle(GetPlayerVehicleID(playerid), Pa);
}
However that works on angles, if you want to know if they are in the player's line of sight, you will have to use some maths with GetPlayerCameraPos and GetPlayerCameraFrontVector..
Reply


Messages In This Thread
IsPlayerLookingAtPlayer problem - by legodude - 20.04.2012, 15:52
Re: IsPlayerLookingAtPlayer problem - by MP2 - 20.04.2012, 15:56
Re: IsPlayerLookingAtPlayer problem - by legodude - 20.04.2012, 17:10
Re: IsPlayerLookingAtPlayer problem - by Ainseri - 20.04.2012, 17:22
Re: IsPlayerLookingAtPlayer problem - by MP2 - 20.04.2012, 17:35
Re: IsPlayerLookingAtPlayer problem - by Ainseri - 20.04.2012, 18:00

Forum Jump:


Users browsing this thread: 1 Guest(s)