All pastes #569854 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-16 13:09 UTC
rendered paste body
Float:GetPlayerTheoreticAngle(i)
{
 new Float:sin;
 new Float:dis;
 new Float:angle2;
 new Float:x,Float:y,Float:z;
 new Float:tmp3;
 new Float:tmp4;
 new Float:MindAngle;
 if(IsPlayerConnected(i)){
  GetPlayerPos(i,x,y,z);
  dis = floatsqroot(floatpower(floatabs(floatsub(x,ppos[i][0])),2)+floatpower(floatabs(floatsub(y,ppos[i][1])),2));
  if(IsPlayerInAnyVehicle(i))GetVehicleZAngle(GetPlayerVehicleID(i), angle2); else GetPlayerFacingAngle(i, angle2);
  if(x>ppos[i][0]){tmp3=x-ppos[i][0];}else{tmp3=ppos[i][0]-x;}
  if(y>ppos[i][1]){tmp4=y-ppos[i][1];}else{tmp4=ppos[i][1]-y;}
  if(ppos[i][1]>y && ppos[i][0]>x){ //1
   sin = asin(tmp3/dis);
   MindAngle = floatsub(floatsub(floatadd(sin, 90), floatmul(sin, 2)), -90.0);
  }
  if(ppos[i][1]<y && ppos[i][0]>x){ //2
  sin = asin(tmp3/dis);
  MindAngle = floatsub(floatadd(sin, 180), 180.0);
  }
  if(ppos[i][1]<y && ppos[i][0]<x){ //3
  sin = acos(tmp4/dis);
  MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
  }
  if(ppos[i][1]>y && ppos[i][0]<x){ //4
  sin = asin(tmp3/dis);
  MindAngle = floatadd(sin, 180);
  }
 }
 return MindAngle;
}
#pragma unused GetPlayerTheoreticAngle