SA-MP Forums Archive
GetWhereIsPlayerLook - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: GetWhereIsPlayerLook (/showthread.php?tid=182713)



GetWhereIsPlayerLook - cca - 12.10.2010

I have this:
pawn Код:
stock IsPlayerLookingAtPoint(playerid,Float:X,Float:Y,Float:Z,Float:ViewWidth,Float:ViewHeight)
{
    new Float:cx,Float:cy,Float:cz,Float:pa1,Float:pa2,Float:ca1,Float:ca2,Float:px,Float:py,Float:pz;
    GetPlayerCameraFrontVector(playerid,cx,cy,cz);
    GetPlayerPos(playerid,px,py,pz);
    pz+=2.0;
    cx=floatadd(cx,px);
    cy=floatadd(cy,py);
    cz=floatadd(cz,pz);
    pa1=atan2(X-px,Y-py);
    if(pa1>360)pa1=floatsub(pa1,360);
    if(pa1<0)pa1=floatadd(pa1,360);
    pa2=atan2(Y-py,Z-pz);
    if(pa2>360)pa2=floatsub(pa2,360);
    if(pa2<0)pa2=floatadd(pa2,360);
    ca1=atan2(cx-px,cy-py);
    if(ca1>360)ca1=floatsub(ca1,360);
    if(ca1<0)ca1=floatadd(ca1,360);
    ca2=atan2(cy-py,cz-pz);
    if(ca2>360)ca2=floatsub(ca2,360);
    if(ca2<0)ca2=floatadd(ca2,360);
    if((ca1>(pa1-ViewWidth))&&(ca1<(pa1+ViewWidth))&&(ca2>(pa2-ViewHeight))&&(ca2<(pa2+ViewHeight)))return 1;
    if((pa1-ViewWidth)<0)
    {
        ca1-=360.0;
        if((ca1>(pa1-ViewWidth))&&(ca1<(pa1+ViewWidth))&&(ca2>(pa2-ViewHeight))&&(ca2<(pa2+ViewHeight)))return 1;
    }
    if((pa1+ViewWidth)>360)
    {
        ca1+=360.0;
        if((ca1>(pa1-ViewWidth))&&(ca1<(pa1+ViewWidth))&&(ca2>(pa2-ViewHeight))&&(ca2<(pa2+ViewHeight)))return 1;
    }
    return 0;
}
from https://sampforum.blast.hk/showthread.php?tid=136868
but I need this plaese:
pawn Код:
GetWhereIsPlayerLook(playerid, Float:X,Float:Y,Float:Z,Float:ViewWidth,Float:ViewHeight)



Re: GetWhereIsPlayerLook - DevilG - 12.10.2010

I'm sorry? I don't get it.. Do you ask for a function that do exactly the same like IsPlayerLookAtPoint, or you look for a function that set player to look at a point?


Re: GetWhereIsPlayerLook - Mike_Peterson - 12.10.2010

I'd earlier think that he wants to see where the player is looking at... and returns the co-ordinates
This is to find out if the player is looking at a certain point...


Re: GetWhereIsPlayerLook - cca - 12.10.2010

Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
I'd earlier think that he wants to see where the player is looking at... and returns the co-ordinates
This is to find out if the player is looking at a certain point...
you get it so
can any one plaese do it plaese


Re: GetWhereIsPlayerLook - cca - 12.10.2010

for who did not understand:
pawn Код:
new Float:X, Float:Z, Float:Z, Float:ViewWidth,Float:ViewHeight;
    GetWhereIsPlayerLook(playerid, Float:X, Float:Z, Float:Z, Float:ViewWidth,Float:ViewHeight); //this is the effect I need.
    if(IsPlayerLookingAtPoint(playerid,Float:X,Float:Y,Float:Z,Float:ViewWidth,Float:ViewHeight)
    (
        //Something Here
    }
that was what I mean


Re: GetWhereIsPlayerLook - cca - 13.10.2010

Help help


Re: GetWhereIsPlayerLook - Hiddos - 13.10.2010

Meh, would be possible but not easy, you can only retrieve the line that 'travels' from the camera position to infinity. You'd need to use MapAndreas tot try to get an accurate ground position, not mentioning that 3D position would totally be awkward.

Best chance is to set a few points and use IsPlayerLookingAtPoint to try getting something accurate, this isn't easy.


Re: GetWhereIsPlayerLook - CracK - 13.10.2010

This can be helpful for you - http://forum.sa-mp.com/showpost.php?...6&postcount=14
It uses only distance instead of width and height though


Re: GetWhereIsPlayerLook - cca - 13.10.2010

help help


Re: GetWhereIsPlayerLook - cca - 13.10.2010

Quote:
Originally Posted by cca
Посмотреть сообщение
help help
plaese help