zRayzHaze

All Client Stats (AdvancedWarfare/Ghost)

Dec 11th, 2022 (edited)
62
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.15 KB | Source Code | 0 0
  1. struct msg_t
  2. {
  3.         int overflowed;
  4.         int readOnly;
  5.         char* data;
  6.         char* splitData;
  7.         int maxsize;
  8.         int cursize;
  9.         int splitSize;
  10.         int readcount;
  11.         int bit;
  12.         int lastEntityRef;
  13.         int targetLocalNetID;
  14.         int useZlib;
  15. };
  16.  
  17. opd_s SV_SendServerCommandMsg_t = { 0x450BDC, TOC };
  18. void(*SV_SendServerCommandMsg)(int clientNum, svscmd_type type, msg_t * msg) = (void(*)(int, svscmd_type, msg_t *))&SV_SendServerCommandMsg_t;
  19. opd_s SV_GetClientPersistentDataBuffer_t = { 0x446FF8, TOC };
  20. char *(*SV_GetClientPersistentDataBuffer)(int clientNum) = (char *(*)(int))&SV_GetClientPersistentDataBuffer_t;
  21.  
  22. int Client_t(int clientNum)
  23. {
  24.         return *(int*)0x223A190 + (0x46480 * clientNum);
  25. }
  26.  
  27. char * GetClientCurrentStatValue(int clientNum, int statIndex)
  28. {
  29.         return SV_GetClientPersistentDataBuffer(clientNum) + statIndex;
  30. }
  31.  
  32. msg_t msg;
  33. char msgBuffer[0x400];
  34.  
  35. void AllocateMsg()
  36. {
  37.         memset(msgBuffer, 0, 0x400);
  38.         memset(&msg, 0, 0x48);
  39. }
  40.  
  41. void MSG_Init(msg_t *buf, char *data, int length)
  42. {
  43.         buf->overflowed = 0;
  44.         buf->readOnly = 0;
  45.         buf->data = data;
  46.         buf->splitData = 0;
  47.         buf->maxsize = length;
  48.         buf->cursize = 0;
  49.         buf->splitSize = 0;
  50.         buf->readcount = 0;
  51.         buf->bit = 0;
  52.         buf->lastEntityRef = 0;
  53.         buf->targetLocalNetID = 0;
  54.         buf->useZlib = 0;
  55. }
  56.  
  57. void MSG_WriteByte(msg_t *msg, int c)
  58. {
  59.         if (msg->cursize >= msg->maxsize)
  60.                 msg->overflowed = 1;
  61.         else
  62.                 msg->data[msg->cursize++] = c;
  63. }
  64.  
  65. void MSG_WriteLong(msg_t *msg, int c)
  66. {
  67.         int32_t *dst;
  68.  
  69.         if (msg->maxsize - msg->cursize < 4)
  70.         {
  71.                 msg->overflowed = 1;
  72.         }
  73.         dst = (int32_t*)&msg->data[msg->cursize];
  74.         *dst = c;
  75.         msg->cursize += sizeof(int32_t);
  76. }
  77.  
  78. void MSG_WriteData(msg_t *buf, const void *data, int lenght)
  79. {
  80.         for(int i = 0; i < lenght; i++)
  81.         {
  82.                 MSG_WriteByte(buf, ((char*)data)[i]);
  83.         }
  84. }
  85.  
  86. void strncpyz(char *dest, const char *src, int destsize)
  87. {
  88.         strncpy(dest, src, destsize - 1);
  89.         dest[destsize-1] = 0;
  90. }
  91.  
  92. void MSG_WriteString(msg_t *sb, const char *s)
  93. {
  94.         if (!s)
  95.         {
  96.                 MSG_WriteData(sb, "", 1);
  97.         }
  98.         else
  99.         {
  100.                 int l;
  101.                 char string[0x400];
  102.  
  103.                 l = strlen(s);
  104.                 if (l >= 0x400)
  105.                 {
  106.                         MSG_WriteData(sb, "", 1);
  107.                 }
  108.                 strncpyz(string, s, sizeof(string));
  109.                 MSG_WriteData(sb, string, l + 1);
  110.         }
  111. }
  112.  
  113. void MSG_WriteBits(msg_t *msg, int bits, int bitcount)
  114. {
  115.         if (msg->maxsize - msg->cursize < 4)
  116.     {
  117.         msg->overflowed = 1;
  118.     }
  119.  
  120.     if (bitcount)
  121.     {
  122.                 for (int i = 0; bitcount != i; i++)
  123.                 {
  124.                         if (!(msg->bit & 7))
  125.                         {
  126.                                 msg->bit = 8 * msg->cursize;
  127.                                 msg->data[msg->cursize] = 0;
  128.                                 msg->cursize++;
  129.                         }
  130.  
  131.                         if (bits & 1)
  132.                                 msg->data[msg->bit >> 3] |= 1 << (msg->bit & 7);
  133.  
  134.                         msg->bit++;
  135.                         bits >>= 1;
  136.                 }
  137.         }
  138. }
  139.  
  140. void MSG_WriteShort(msg_t *msg, int c)
  141. {
  142.         signed short* dst;
  143.  
  144.         if (msg->maxsize - msg->cursize < 2)
  145.         {
  146.                 msg->overflowed = 1;
  147.         }
  148.         dst = (short*)&msg->data[msg->cursize];
  149.         *dst = c;
  150.         msg->cursize += sizeof(short);
  151. }
  152.  
  153. void SetStatsInt(int clientNum, int statIndex, int value)
  154. {
  155.         AllocateMsg();
  156.         MSG_Init(&msg, msgBuffer, 0x400);
  157.         MSG_WriteByte(&msg, 0x47);
  158.         MSG_WriteLong(&msg, statIndex);
  159.         MSG_WriteByte(&msg, sizeof(value));
  160.         MSG_WriteBits(&msg, value, 32);
  161.         SV_SendServerCommandMsg(Client_t(clientNum), SV_CMD_RELIABLE, &msg);
  162. }
  163.  
  164. void SetStatsBytes(int clientNum, int statIndex, const void * value)
  165. {
  166.         AllocateMsg();
  167.         MSG_Init(&msg, msgBuffer, 0x400);
  168.         MSG_WriteByte(&msg, 0x47);
  169.         MSG_WriteLong(&msg, statIndex);
  170.         MSG_WriteByte(&msg, sizeof(value));
  171.         MSG_WriteData(&msg, value, sizeof(value));
  172.         SV_SendServerCommandMsg(Client_t(clientNum), SV_CMD_RELIABLE, &msg);
  173. }
  174.  
  175. void SetStatsString(int clientNum, int statIndex, const char * value)
  176. {
  177.         AllocateMsg();
  178.         MSG_Init(&msg, msgBuffer, 0x400);
  179.         MSG_WriteByte(&msg, 0x47);
  180.         MSG_WriteLong(&msg, statIndex);
  181.         MSG_WriteByte(&msg, strlen(value));
  182.         MSG_WriteString(&msg, value);
  183.         SV_SendServerCommandMsg(Client_t(clientNum), SV_CMD_RELIABLE, &msg);
  184. }
  185.  
  186. enum statIndex
  187. {
  188.         Prestige = 0x9,
  189.         RankXP = 0xA5,
  190.         Score = 0xE2,
  191.         Kills = 0xB9,
  192.         Deaths = 0x91,
  193.         Wins = 0x10E,
  194.         Losses = 0xC1,
  195.         GamesPlayed = 0xA9,
  196.         Accuracy = 0x4D,
  197.         Class1Name = 0x4DE5
  198. };
Comments
Add Comment
Please, Sign In to add comment