28.02.2014, 10:38
How can i detect if a player is aiming at another players back?
Thanks!
Thanks!
stock GetXYBehindPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
a +=180;
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
stock IsPlayerBehindPlayer(playerid,targetid,Float:distance,Float:range)
{
if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid))return 0;
{
new Float:x, Float:y, Float:z;
GetPlayerPos(targetid, x, y, z);//my pos
GetXYBehindPlayer(targetid,x,y,distance);
if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))return 1;
}
return 0;
}