Advertisement
Guest User

Untitled

a guest
Jun 14th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.62 KB | None | 0 0
  1. stock SetPlayerFacePoint(playerid, Float:x, Float:y) {
  2.     if (playerid < 0 || playerid >= MAX_PLAYERS)
  3.         return 0;
  4.  
  5.     new Float:px, Float:py, Float:pz;
  6.     GetPlayerPos(playerid, px, py, pz);
  7.    
  8.     new Float:angle = acos((x - px) / floatsqroot(((x - px) * (x - px)) + ((y - py) * (y - py)));
  9.  
  10.     if (y > py)
  11.         angle = -angle - 90.0;
  12.     else if (y < py && x < px)
  13.         angle -= 450.0;
  14.     else if (y < py)
  15.         angle -= 90.0;
  16.  
  17.     if (x > px)
  18.         angle = floatabs(angle) + 180.0;
  19.     else
  20.         angle = floatabs(angle) - 180.0;
  21.    
  22.     return SetPlayerFacingAngle(playerid, angle);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement