firefighter problem
#2

Try using something like this:
Код:
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;
}
Reply


Messages In This Thread
firefighter problem - by Unknown123 - 09.01.2012, 00:53
Re: firefighter problem - by Vortrex - 09.01.2012, 06:54

Forum Jump:


Users browsing this thread: 1 Guest(s)