IsPlayerLookingAtPlayer problem
#1

i ******d some, and they dont seem to work, because they all miss the function GetPlayerCameraUpVector

does anybody know how to create such a function? my math isn't what it should be
rep+ will be given to the ones that helped me
Reply
#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
#3

nope, it is only 2d it does the x and the y. i need z too.
lets say the aiming with the sniper should activate a textdraw if someones aiming on somebody else
Reply
#4

It's not possible.
Reply
#5

If you want to detect aiming, use GetPlayerTargetPlayer. This has three drawbacks however: it must be checked often (OnPlayerUpdate?), it does not work far away or with joypads.

It's the little green arrow above players' heads when you aim at them.
Reply
#6

Actually, it might be possible using GetPlayerTargetPlayer as MP2 said or GetPlayerCameraFrontVector.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)