IsPlayerFacingPlayer
#4

Okay, what about these?

pawn Code:
stock Float:PlayerAngle(playerid)
{
new Float:Angle;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
else GetPlayerFacingAngle(playerid, Angle);
return Angle;
}

stock bool:IsPlayerFacingPoint(playerid, Float:PointX, Float:PointY, Float:Range = 10.0)
{
new Float:FacingAngle = PlayerAngle(playerid), Float:Angle;
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X > PointX && Y > PointY) Angle = floatabs(atan2(floatsub(PointX, X), floatsub(PointY, Y)));
if(X > PointX && Y <= PointY) Angle = floatadd(floatabs(atan2(floatsub(Y, PointY), floatsub(PointX, X))), 270.0);
if(X <= PointX && Y > PointY) Angle = floatadd(floatabs(atan2(floatsub(PointY, Y), floatsub(X, PointX))), 90.0);
if(X <= PointX && Y <= PointY) Angle = floatadd(floatabs(atan2(floatsub(X, PointX), floatsub(Y, PointY))), 180.0);
Range /= 2.0;
return floatabs(floatsub(FacingAngle, Angle)) <= floatabs(Range) || floatabs(floatsub(floatadd(FacingAngle, 360.0), Angle)) <= floatabs(Range);
}

stock bool:IsPlayerFacingPlayer(playerid, faceplayerid, Float:Range = 10.0)
{
if(playerid == faceplayerid) return false;
new Float:X, Float:Y, Float:Z;
GetPlayerPos(faceplayerid, X, Y, Z);
return IsPlayerFacingPoint(playerid, X, Y, Range);
}

stock Float:SetPlayerFaceToPoint(playerid, Float:PointX, Float:PointY)
{
new Float:X, Float:Y, Float:Z;
new Float:Angle;
GetPlayerPos(playerid, X, Y, Z);
if(X > PointX && Y > PointY) Angle = floatabs(atan2(floatsub(PointX, X), floatsub(PointY, Y)));
if(X > PointX && Y <= PointY) Angle = floatadd(floatabs(atan2(floatsub(Y, PointY), floatsub(PointX, X))), 270.0);
if(X <= PointX && Y > PointY) Angle = floatadd(floatabs(atan2(floatsub(PointY, Y), floatsub(X, PointX))), 90.0);
if(X <= PointX && Y <= PointY) Angle = floatadd(floatabs(atan2(floatsub(X, PointX), floatsub(Y, PointY))), 180.0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
else SetPlayerFacingAngle(playerid, Angle);
return Angle;
}

stock Float:SetPlayerFaceFromPoint(playerid, Float:PointX, Float:PointY)
{
new Float:Angle = floatadd(SetPlayerFaceToPoint(playerid, PointX, PointY), 180.0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) SetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
else SetPlayerFacingAngle(playerid, Angle);
return Angle;
}

stock Float:SetPlayerFaceToPlayer(playerid, faceplayerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(faceplayerid, X, Y, Z);
return SetPlayerFaceToPoint(playerid, X, Y);
}

stock Float:SetPlayerFaceFromPlayer(playerid, faceplayerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(faceplayerid, X, Y, Z);
return SetPlayerFaceFromPoint(playerid, X, Y);
}
Reply


Messages In This Thread
IsPlayerFacingPlayer - by Nakash - 25.04.2010, 13:53
Re: IsPlayerFacingPlayer - by ¤Adas¤ - 25.04.2010, 14:12
Re: IsPlayerFacingPlayer - by Nakash - 25.04.2010, 14:27
Re: IsPlayerFacingPlayer - by ¤Adas¤ - 25.04.2010, 14:30

Forum Jump:


Users browsing this thread: 2 Guest(s)