IsPlayerLookAt Function
#1

Can someone help me with this function, I can't figure out what to do next

pawn Код:
public IsPlayerLookAt(playerid,Float:range,Float:x,Float:y,Float:z)
{
    if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))
    {
        new Float:Face;
        GetPlayerFacingAngle(playerid,Face);
        return floatsqroot(...
    }
}
Reply
#2

what do you want to do with it ? maybe i could help you then
Reply
#3

I want get if player look at house entrance

here is what I done so far, haven't tested yet.
pawn Код:
public IsPlayerLookAt(playerid,Float:range,Float:x,Float:y,Float:z)
{
    if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))
    {
        new Float:Face,Float:FaceX,Float:FaceY,Float:FaceZ;
        GetPlayerPos(playerid,FaceX,FaceY,FaceZ);
        GetPlayerFacingAngle(playerid,Face);
        if(FaceX > 0 && FaceY > 0) { if(Face > -1 && Face < 91) { return 1; } }
        if(FaceX < 0 && FaceY > 0) { if(Face > 89 && Face < 181) { return 1; } }
        if(FaceX < 0 && FaceY < 0) { if(Face > 179 && Face < 271) { return 1; } }
        if(FaceX > 0 && FaceY < 0) { if(Face > 269 && Face < -1) { return 1; } }
    }
    return 0;
}
Reply
#4

well you need to find the x,y,z position of the house entrance then you could use it
however..im not sure this 'isplayerlookat' thingy of yours will work.
Reply
#5

pawn Код:
public IsPlayerLookAt(playerid, Float:range, Float:x, Float:y, Float:z, Float:max_al, Float:max_ar)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInRangeOfPoint(i, range, x, y, z))
        {
            // max_al = max angle left
            // max_ar = max angle right
            // max_al && max_ar coordinates at the top
            new Float:angle;
            GetPlayerFacing(i, angle);
            if(angle > max_al && angle < max_ar) return 1;
            else return 0;
        }
        else return 0;
    }
    return 0;
}
Check this ^
Try it, might give good results
Reply
#6

Quote:
Originally Posted by Claude
Посмотреть сообщение
[pawn]

Check this ^
Try it, might give good results
I used max_al and r value : 45

but its seems to not work.
Reply
#7

pawn Код:
public IsPlayerLookAt(playerid, const Float:range,
    const Float:x, const Float:y, const Float:z, const Float:max_al, const Float:max_ar)
{
    if(IsPlayerInRangeOfPoint(playerid, range, x, y, z))
    {
        new Float:angle, Float:Pos[3];
        GetPlayerFacingAngle(playerid, angle);
        GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
        if(Pos[0] > x) angle -= (atan( (Pos[1] - y) / (Pos[0] - x) ) + 90.0);
        else           angle -= (atan( (Pos[1] - y) / (Pos[0] - x) ) + 270.0);
        if(angle < 0) {
            if((angle > -max_al) || ((angle + 360.0) < max_ar)) return 1;
        } else {
            if((angle < max_ar) || ((angle - 360.0) > -mal_al)) return 1;
        }
    }
    return 0;
}
Not tested but actually I thought that there were already an include with such functions released
Reply
#8

Quote:

Not tested but actually I thought that there were already an include with such functions released

Me too, but I search some half hour w/o results, btw, which values I need to write in Max_al and r ?


EDIT: Tested and its working perfectly, now firefighters really need to look at house to bring fire under control.

You save my day
Reply
#9

Ah found it [INC] a_angles by Tannz0rz

And now I know again why I didnt use it because he calculates the angle with cosine not like I with tangent
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)