Is player facing speed camera
#1

Hello there,
I need to check if is player's vehicle facing speed camera (with maximum difference about 40 degrees), so that if player'd speed over the camera, it will trigger alert to the police. But, if player won't be facing the camera (he would be not like this ( > < ), it won't get triggered.

I need it to be triggered just like this, > <, not like this > > or > V or this > ^

It shouldn't be constant, I will place more speed cameras and I need it to work on every camera.

Camera angle is stored in spdcamEnum[i][scam_RZ], then in spdcma, vehicle's angle is stored in angle.

Here is my actual code.

Код:
new
   Float:spdcma= spdcamEnum[i][scam_RZ]-180,
   Float:angle;
			    
   GetVehicleZAngle(GetPlayerVehicleID(playerid), angle);
			
   ValidateDegree(spdcma); // After editing object degrees can be negative or bigger than 360 degrees, so lets fix it.
   ValidateDegree(angle);
			
   if(spdcma < angle + 45 && spdcma > angle - 45)
       continue; //Player shouldn't be facing speed camera


//-------------------------

ValidateDegree(&Float:degree)
{
    if(degree < 0.0)
		degree = degree * -1 + 180;

	if(degree > 360)
	    degree -= 360.0;
}
This code appears to not work, as it is working just in some cases, it appears to be random. Does anyone have better solution, please?

> - speed cam
< / v / ^ - player's vehicle
Reply


Messages In This Thread
Is player facing speed camera - by Bigwebicek - 01.07.2017, 07:05
Re: Is player facing speed camera - by Nero_3D - 01.07.2017, 14:49
Re: Is player facing speed camera - by Bigwebicek - 01.07.2017, 19:29

Forum Jump:


Users browsing this thread: 1 Guest(s)