19.01.2010, 21:09
Thank you for your reply, but I can't seem to get it working. It always returns true, on every angle (well, I tried with 0.01, 1.0 and 20.5). Also tried switching the coords, like the comment shows
object[0], object[1] and object[2] being x, y and z coords.
edit:
trying with the a_angles include
pawn Код:
IsVehicleInObjectDirection(vehicleid, Float:angle)
{
/*
new Float:px = object[0],
Float:py = object[1],
Float:pz = object[2];
new Float:x,Float:y,Float:a;
GetVehiclePos(vehicleid, x, y, a);
*/
new Float:x = object[0],
Float:y = object[1],
Float:a = object[2];
new Float:px,Float:py,Float:pz;
GetVehiclePos(vehicleid, px, py, pz);
a = floatabs(atan((py-y)/(px-x)));
if (px <= x && py >= y) a = floatsub(180, a);
else if (px < x && py < y) a = floatadd(a, 180);
else if (px >= x && py <= y) a = floatsub(360.0, a);
a = floatsub(a, 90.0);
if (a >= 360.0) a = floatsub(a, 360.0);
if (a >= (a-angle) && a <= (a+angle)) return 1;
return 0;
}
edit:
trying with the a_angles include