Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. //usage: if (GetPlayerEye(client, buffer)) // if hits = true | if not = false, buffer will be the new pos client is looking.
  2.  
  3. stock bool GetPlayerEye(int client, float vecPos[3]) {
  4. if (!IsValidClient(client))
  5. return false;
  6.  
  7. float vecAngles[3], vecOrigin[3];
  8.  
  9. GetClientEyePosition(client, vecOrigin);
  10. GetClientEyeAngles(client, vecAngles);
  11.  
  12. Handle hTrace = TR_TraceRayFilterEx(vecOrigin, vecAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
  13.  
  14. if (TR_DidHit(hTrace)) {
  15. //This is the first function i ever saw that anything comes before the handle
  16. TR_GetEndPosition(vecPos, hTrace);
  17. CloseHandle(hTrace);
  18.  
  19. return true;
  20. }
  21.  
  22. CloseHandle(hTrace);
  23.  
  24. return false;
  25. }
  26.  
  27. public bool TraceEntityFilterPlayer(entity, contentsMask)
  28. {
  29. return (entity > MaxClients || !entity);
  30. }
  31.  
  32. public bool IsValidClient(int client)
  33. {
  34. if (client <= 0)
  35. return false;
  36.  
  37. if (client > GetMaxClients())
  38. return false;
  39.  
  40. if (!IsClientInGame(client))
  41. return false;
  42.  
  43. if (!IsClientAuthorized(client))
  44. return false;
  45.  
  46. if (IsFakeClient(client))
  47. return false;
  48.  
  49. return true;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement