PDA

View Full Version : firefighter problem


Unknown123
09/01/2012, 12:53 AM
stock IsPlayerAimingAtFire(playerid, fireid)
{
new Float:x = fireInfo[fireid][fireX];
new Float:y = fireInfo[fireid][fireY];
new Float:z = fireInfo[fireid][fireZ];
if(!IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerAimingAt(playerid, x, y, z-0.75, 1)) return 1;
if(IsPlayerAimingAt(playerid, x, y, z+0.25, 1)) return 1;
}
else
{
if(IsPlayerAimingAt(playerid, x, y, z - 3.0, 1)) return 1;
}
return 0;
}


does someone have a better code? when im inside a vehicle i can only put out the fire when the firetruck z-angle is same way as a fire. but i want it to put out a fire at any vehicle z-rot (but the player must aim with the water conon at the fire)



^*^ = fire
|<<o_o<<| = firetruck



Works
^*^ |<<o_o<<|

Dont work
^*^

|<<o_o<<|

Vortrex
09/01/2012, 06:54 AM
Try using something like this:

stock IsPlayerLookingAtPoint(playerid,Float:X,Float:Y,Fl oat:Z,Float:ViewWidth,Float:ViewHeight)
{
new Float:cx,Float:cy,Float:cz,Float:pa1,Float:pa2,Flo at: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;
}