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;
pa1=atan2(X-px,Y-py);
if(pa1>360)pa1=floatsub(pa1,360);
pa2=atan2(Y-py,Z-pz);
if(pa2>360)pa2=floatsub(pa2,360);
ca1=atan2(cx-px,cy-py);
if(ca1>360)ca1=floatsub(ca1,360);
ca2=atan2(cy-py,cz-pz);
if(ca2>360)ca2=floatsub(ca2,360);