native IsPlayerFacingPlayer(playerid, targetid, Float:range = 10.0);
stock IsPlayerInFrontOfPlayer(playerid)
{
new Float:x, Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, z);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
new i;
for(i; i < MAX_PLAYERS;i++)
{
if(i == playerid) continue;
IsPlayerInRangeOfPoint(i,3.0,x,y,z) return i;
}
}
stock IsPlayerInFrontOfVehicle(vehicleid)
{
new Float:x, Float:y,Float:z;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleFacingAngle(vehicleid, z);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
new i;
for(i; i < MAX_PLAYERS;i++)
{
IsPlayerInRangeOfPoint(i,3.0,x,y,z) return i;
}
}
|
stock GetXYInFrontOfPlayer(playerid, &Float , &Float:y, Float:distance){ new Float:a; GetPlayerPos(playerid, x, y, a); GetPlayerFacingAngle(playerid, a); if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); } x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); } bool:IsPlayerFrontOfPlayer(playerid, targetid, Float:max_distance=10.0) { new Float [2][3];new Float:radius = 2.0; if(IsPlayerInAnyVehicle(targetid)) radius = 5.0; GetPlayerPos(playerid, p[0][0], p[0][1], p[0][2]); GetPlayerPos(targetid, p[1][0], p[1][1], p[1][2]); if(IsPlayerInRangeOfPoint(targetid, radius, p[0][0], p[0][1], p[0][2])) return false; for(new Float:i = 3.5; i < max_distance; i++) { GetXYInfrontOfPlayer(playerid, p[0][0], p[0][1], i); if(IsPlayerInRangeOfPoint(targetid, radius, p[0][0], p[0][1], p[0][2])) { return true; } } return false; } |