shiftandzplz

Untitled

Jan 11th, 2021 (edited)
503
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void cScr::Scr_SetPerk(int clientNum, std::string perkName, bool loadClass) {
  2.     if (perkName == "specialty_explosivebullets") {
  3.         pUnknown->iprintln(clientNum, pUnknown->va("^1Perk: %s Is Forbidden!", perkName.c_str()));
  4.         return;
  5.     }
  6.  
  7.     if (pScr->Scr_HasPerk(clientNum, perkName)) {
  8.         pUnknown->iprintln(clientNum, pUnknown->va("^1U already have this perk!", perkName.c_str()));
  9.         return;
  10.     }
  11.  
  12.     int g_entities = (0x0194B9D0 + (clientNum * 0x274));
  13.     int playerState = *(int*)(g_entities + 0x158);
  14.     int perkIndex = pPerk->Perk_GetSlotIndexName(perkName.c_str());
  15.     int slotIndex = pPerk->Perk_GetSlotIndex(perkIndex);
  16.  
  17.     *(int*)(playerState + (4 * slotIndex) + 0x430) = perkIndex;
  18.  
  19.     if (loadClass) {
  20.         unsigned int perk;
  21.         perk = pBG->BG_GetPerkCodeIndexForName(perkName.c_str());
  22.  
  23.         if (perk == 36) {
  24.             return;
  25.         }
  26.  
  27.         int perkToWrite = 1 << (perk & 0x1F);
  28.         int perkSlot = perk >> 5;
  29.  
  30.         *(int*)(playerState + (4 * perkSlot) + 0x428) |= perkToWrite;
  31.         *(int*)(playerState + (4 * perkSlot) + 0x3238) |= perkToWrite;
  32.     }
  33. }
  34.  
  35. void cScr::Scr_UnsetPerk(int clientNum, std::string perkName, bool loadClass) {
  36.     int g_entities = (0x0194B9D0 + (clientNum * 0x274));
  37.     int playerState = *(int*)(g_entities + 0x158);
  38.     int perkIndex = pPerk->Perk_GetSlotIndexName(perkName.c_str());
  39.     int slotIndex = pPerk->Perk_GetSlotIndex(perkIndex);
  40.  
  41.     if (!pScr->Scr_HasPerk(clientNum, perkName)) {
  42.         pUnknown->iprintln(clientNum, pUnknown->va("^1U don't have %s!", perkName.c_str()));
  43.         return;
  44.     }
  45.  
  46.     *(int*)(playerState + (4 * slotIndex) + 0x430) = 0;
  47.  
  48.     if (loadClass) {
  49.         unsigned int perk;
  50.         perk = pBG->BG_GetPerkCodeIndexForName(perkName.c_str());
  51.  
  52.         if (perk == 36) {
  53.             return;
  54.         }
  55.  
  56.         int perkToWrite = ~(1 << (perk & 0x1F));
  57.         int perkSlot = perk >> 5;
  58.  
  59.         *(int*)(playerState + (4 * perkSlot) + 0x428) &= perkToWrite;
  60.         *(int*)(playerState + (4 * perkSlot) + 0x3238) &= perkToWrite;
  61.     }
  62. }
  63.  
  64. bool cScr::Scr_HasPerk(int clientNum, std::string perkName, bool loadClass) {
  65.     bool result = false;
  66.     int g_entities = (0x0194B9D0 + (clientNum * 0x274));
  67.     int playerState = *(int*)(g_entities + 0x158);
  68.     int perkIndex = pPerk->Perk_GetSlotIndexName(perkName.c_str());
  69.     int slotIndex = pPerk->Perk_GetSlotIndex(perkIndex);
  70.  
  71.     if (loadClass) {
  72.         unsigned int perk;
  73.         perk = pBG->BG_GetPerkCodeIndexForName(perkName.c_str());
  74.  
  75.         if (perk == 36)
  76.             return false;
  77.  
  78.         int perkToWrite = (1 << (perk & 0x1F));
  79.         int perkSlot = perk >> 5;
  80.  
  81.         result = (*(int*)(playerState + (4 * perkSlot) + 0x428) & perkToWrite);
  82.     }
  83.     return result;
  84. }
  85.  
  86. class cPerk {
  87. public:
  88.  
  89.     typedef int (__cdecl* tPerk_GetSlotIndexName)(const char* perkName);
  90.     tPerk_GetSlotIndexName Perk_GetSlotIndexName = (tPerk_GetSlotIndexName)0x0046BC00;
  91.  
  92.     typedef int(__cdecl* tPerk_GetSlotIndex)(int perkName);
  93.     tPerk_GetSlotIndex Perk_GetSlotIndex = (tPerk_GetSlotIndex)0x0046BC30;
  94.  
  95.     typedef bool(__cdecl* tPerk_GetIndex)(const char* perkName, int* perkIndex);
  96.     tPerk_GetIndex Perk_GetIndex = (tPerk_GetIndex)0x0046BC70;
  97.  
  98.     typedef bool(__cdecl* tPerk_GetName)(unsigned int perkIndex, const char** perkName);
  99.     tPerk_GetName Perk_GetName = (tPerk_GetName)0x0046BCC0;
  100.  
  101. };
  102.  
  103. extern cPerk* pPerk;
RAW Paste Data