09.03.2014, 16:20
I need to ask here cuz I can't test on my own :/
Is this code right or is there any mistake?
What I want to detect are coords behind player for /cuff and /uncuff cmd ^^, thanks for checking and answering.
Is this code right or is there any mistake?
pawn Код:
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
GetXYInBehindPlayer(targetid,x,y,distance);
if(IsPlayerInRangeOfPoint(playerid,range,x,y,z))return 1;
}
return 0;
}
pawn Код:
stock GetXYInBehindPlayer(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.0;
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}