Advertisement
ThePJ120

Mw3 Host SPRX Aimbot

Jan 4th, 2015
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. namespace Func
  2. {
  3. int G_Client(int clientIndex) {return Offsets::G_Client_s + ( clientIndex * Offsets::G_ClientSize ); }
  4. int G_Entity(int clientIndex) {return Offsets::G_Entity + ( clientIndex * Offsets::G_EntitySize ); }
  5.  
  6. #pragma region Calls
  7. opd_s Com_sprintf_t = { Offsets::com_sprintf, TOC };
  8. int(*Com_sprintf)(char *dest, int size, const char *fmt, ...) = (int(*)(char* , int, char const *, ...))&Com_sprintf_t;
  9.  
  10. opd_s SV = { Offsets::SV_GameSendServerCommand, TOC };
  11. void(*svgssc)(int client, int type, char* cmd) = (void(*)(int, int, char*))&SV;
  12.  
  13.  
  14. opd_s gs = { Offsets::Dvar_GetString, TOC };
  15. const char*(*Dvar_GetString)(const char* Dvar) = (const char*(*)(const char*))&gs;
  16. #pragma endregion
  17. #pragma region Client functions
  18. #pragma region Sv_GameSendServerCommand
  19. void SV_GSSC(int client, char* command)
  20. {
  21. svgssc(client, 0, command);
  22. }
  23.  
  24. void iPrintlnBold(int client, char* text)
  25. {
  26. char buf[100];
  27. Com_sprintf(buf, 100, "c \"%s%s", text, "\"");
  28. SV_GSSC(client, buf);
  29. }
  30.  
  31. void iPrintln(int client, char* text)
  32. {
  33. char buf[100];
  34. Com_sprintf(buf, 100, "f \"%s%s", text, "\"");
  35. SV_GSSC(client, buf);
  36. }
  37.  
  38. #pragma endregion
  39. bool IsDead(int client)
  40. {
  41. return *(bool*)(G_Client(client) + 0x3313);
  42. }
  43.  
  44. bool CheckTeam(int Client, int OtherClient)
  45. {
  46. int Attacker = *(int*)(G_Client(Client) + 0x33D7);
  47. int Victim = *(int*)(G_Client(OtherClient) + 0x33D7);
  48. if (Attacker == Victim)
  49. {
  50. return true;
  51. }
  52. else
  53. {
  54. return false;
  55. }
  56. }
  57.  
  58. bool CheckIfLiving(int client)
  59. {
  60. if (*(char*)(G_Entity(client) + 0x19F) != 0)
  61. {
  62. return true;
  63. }
  64. else return false;
  65. }
  66.  
  67. bool ClientIsInGame(int clientIndex)
  68. {
  69. if (*(int*)G_Client(clientIndex) != 0)
  70. return true;
  71. else return false;
  72. }
  73.  
  74. struct Vec3
  75. {
  76. float x, y, z;
  77. };
  78.  
  79. Vec3 Difference;
  80. Vec3 GetVec(Vec3 Attacker, Vec3 Target)
  81. {
  82. Difference.x = (Target.x - Attacker.x);
  83. Difference.y = (Target.y - Attacker.y);
  84. Difference.z = (Target.z - Attacker.z);
  85. return Difference;
  86. }
  87.  
  88. float dx, dy, dz;
  89. float Get3dDistance(Vec3 c1, Vec3 c2)
  90. {
  91. float dx = c2.x - c1.x;
  92. float dy = c2.y - c1.y;
  93. float dz = c2.z - c1.z;
  94.  
  95. return sqrt((float)((dx * dx) + (dy * dy) + (dz * dz)));
  96. }
  97.  
  98. Vec3 vec;
  99. Vec3 GetPlayerOrigin(int Client)
  100. {
  101. vec = *(Vec3*)(G_Client(Client) + 0x1C);
  102. return vec;
  103. }
  104.  
  105. Vec3 VecV;
  106. Vec3 GetPlayerOriginVictim(int Client)
  107. {
  108. VecV = *(Vec3*)(G_Client(Client) + 0x1C);
  109. VecV.z -= 24;
  110. return VecV;
  111. }
  112.  
  113. int Nearest;
  114. int GetNearestPlayer(int Client)
  115. {
  116. float MaxDistance = 99999999;
  117. for (int i = 0; i < 12; i++)
  118. {
  119. Vec3 Attacker = GetPlayerOrigin(Client);
  120. Vec3 Vic = GetPlayerOrigin(i);
  121. float ActualDistance = Get3dDistance(Attacker, Vic);
  122. if ((i != Client) && CheckIfLiving(i) && ClientIsInGame(i))
  123. {
  124. if (cstrcmp(Func::Dvar_GetString("ui_gametype"), "dm") == 0)
  125. {
  126. if (ActualDistance < MaxDistance)
  127. {
  128. Nearest = i;
  129. MaxDistance = ActualDistance;
  130. }
  131. }
  132. else
  133. {
  134. if (!CheckTeam(Client, i))
  135. {
  136. if (ActualDistance < MaxDistance)
  137. {
  138. Nearest = i;
  139. MaxDistance = ActualDistance;
  140. }
  141. }
  142. }
  143. }
  144. }
  145. return Nearest;
  146. }
  147.  
  148. float angles[3];
  149. float* vectoangles(Vec3 Angles)
  150. {
  151. float forward;
  152. float yaw, pitch;
  153. float PI = 3.1415926535897931;
  154. if (Angles.x == 0 && Angles.y == 0)
  155. {
  156. yaw = 0;
  157. if (Angles.z > 0) pitch = 90.00;
  158. else pitch = 270.00;
  159. }
  160. else
  161. {
  162. if (Angles.x != -1) yaw = (float)(atan2((double)Angles.y, (double)Angles.x) * 180.00 / PI);
  163. else if (Angles.y > 0) yaw = 90.00;
  164. else yaw = 270;
  165. if (yaw < 0) yaw += 360.00;
  166.  
  167. forward = (float)sqrt((double)(Angles.x * Angles.x + Angles.y * Angles.y));
  168. pitch = (float)(atan2((double)Angles.z, (double)forward) * 180.00 / PI);
  169. if (pitch < 0) pitch += 360.00;
  170. }
  171. angles[0] = -pitch;
  172. angles[1] = yaw;
  173. angles[2] = 0;
  174.  
  175. return angles;
  176. }
  177.  
  178. opd_s Setangles_t = { 0x001767E0, TOC };
  179. void(*SetClientViewAnlges)(int Ent, float* Angles) = (void(*)(int, float*))&Setangles_t;
  180.  
  181. void SetViewAngles(int Client)
  182. {
  183. int Victim = GetNearestPlayer(Client);
  184. float* Angles = vectoangles(GetVec(GetPlayerOrigin(Client), GetPlayerOriginVictim(Victim)));
  185. SetClientViewAnlges(G_Entity(Client), Angles);
  186. }
  187.  
  188. #pragma endregion
  189. #pragma region Game Functions
  190. bool InGame()
  191. {
  192. if (*(char*)Offsets::cl_InGame != 1)
  193. return false;
  194. return true;
  195. }
  196. #pragma endregion
  197. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement