08.10.2014, 01:15
pawn Код:
stock GetPlayerCameraFacingAngle(playerid, &Float:Angle)
{
new Float:X, Float:Y;
new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
new Float:XP,Float:YP,Float:ZP;
if(!IsPlayerInAnyVehicle(playerid))
{
GetPlayerPos(playerid,XP ,YP ,ZP);
GetPlayerCameraPos(playerid, cx, cy, cz);
GetPlayerCameraFrontVector(playerid, fx, fy, fz);
X = fx * 999 + cx;
Y = fy * 999 + cy;
if(Y > YP) Angle = (-acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
if(Y < YP && X < XP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP))) - 450.0);
else if(Y < YP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
if(X > XP) Angle = (floatabs(floatabs(Angle) + 180.0));
else Angle = (floatabs(Angle) - 180.0);
}
else if(IsPlayerInAnyVehicle(playerid))
{
GetVehiclePos(GetPlayerVehicleID(playerid),XP ,YP ,ZP);
GetPlayerCameraPos(playerid, cx, cy, cz);
GetPlayerCameraFrontVector(playerid, fx, fy, fz);
X = fx * 999 + cx;
Y = fy * 999 + cy;
if(Y > YP) Angle = (-acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
if(Y < YP && X < XP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP))) - 450.0);
else if(Y < YP) Angle = (acos((X - XP) / floatsqroot((X - XP)*(X - XP) + (Y - YP)*(Y - YP)))-90.0);
if(X > XP) Angle = (floatabs(floatabs(Angle) + 180.0));
else Angle = (floatabs(Angle) - 180.0);
}
}