Advertisement
Anti-hide

Glove Changer

Nov 30th, 2017
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 KB | None | 0 0
  1. Спойлер: Code(1)
  2. Код:
  3. #pragma once
  4.  
  5. struct WearableItemConfig
  6. {
  7. int iItemDefinitionIndex = 0;
  8. int nFallbackPaintKit = 0;
  9. int nFallbackSeed = 0;
  10. int nFallbackStatTrak = -1;
  11. int iEntityQuality = 4;
  12. float flFallbackWear = 0.1f;
  13. char* szModelFileName = nullptr;
  14. bool bUpdateStatus = false;
  15. };
  16.  
  17. std::unordered_map<int, WearableItemConfig> g_GloveChangerCfg;
  18.  
  19. class GloveFunctions
  20. {
  21. public:
  22. static bool ApplyCustomSkin(C_BaseCombatWeapon* pEntity, int nWeaponIndex)
  23. {
  24. if (g_GloveChangerCfg.find(nWeaponIndex) == g_GloveChangerCfg.end())
  25. return false;
  26.  
  27. *pEntity->GetFallbackPaintKit() = g_GloveChangerCfg[nWeaponIndex].nFallbackPaintKit;
  28. *pEntity->GetEntityQuality() = g_GloveChangerCfg[nWeaponIndex].iEntityQuality;
  29. *pEntity->GetFallbackSeed() = g_GloveChangerCfg[nWeaponIndex].nFallbackSeed;
  30. *pEntity->GetFallbackStatTrak() = g_GloveChangerCfg[nWeaponIndex].nFallbackStatTrak;
  31. *pEntity->GetFallbackWear() = g_GloveChangerCfg[nWeaponIndex].flFallbackWear;
  32.  
  33. if (g_GloveChangerCfg[nWeaponIndex].iItemDefinitionIndex)
  34. *pEntity->GetItemDefinitionIndex() = g_GloveChangerCfg[nWeaponIndex].iItemDefinitionIndex;
  35.  
  36. *pEntity->GetItemIDHigh() = -1;
  37.  
  38. pEntity->SetModelIndex2(Interfaces::ModelInfo()->GetModelIndex(g_GloveChangerCfg[nWeaponIndex].szModelFileName));
  39. pEntity->PreDataUpdate(DATA_UPDATE_CREATED);
  40.  
  41. g_GloveChangerCfg[nWeaponIndex].bUpdateStatus = true;
  42.  
  43. return true;
  44. }
  45.  
  46. static void SetSkinConfig()
  47. {
  48. using namespace SourceEngine;
  49.  
  50. //sample code
  51. g_GloveChangerCfg[0].iItemDefinitionIndex = 5033;
  52. g_GloveChangerCfg[0].nFallbackPaintKit = 10027;
  53. g_GloveChangerCfg[0].nFallbackSeed = 0;
  54. g_GloveChangerCfg[0].flFallbackWear = 0.00000001f;
  55. g_GloveChangerCfg[0].nFallbackStatTrak = -1;
  56. g_GloveChangerCfg[0].szModelFileName = "models/weapons/v_models/arms/glove_motorcycle/v_glove_motorcycle.mdl";
  57. }
  58. };
  59.  
  60.  
  61.  
  62. Спойлер: Code(2)
  63. Код:
  64. DWORD* hMyWearables = (DWORD*)((size_t)pLocal + 0x2EF4);
  65. if (hMyWearables != NULL)
  66. {
  67. for (ClientClass *pClass = Interfaces::Client()->GetAllClasses(); pClass; pClass = pClass->m_pNext)
  68. {
  69. if (pClass->m_ClassID != CEconWearable)
  70. continue;
  71.  
  72. int iEntry = (Interfaces::EntityList()->GetHighestEntityIndex() + 1),
  73. iSerial = RandomInt(0x0, 0xFFF);
  74.  
  75. pClass->m_pCreateFn(iEntry, iSerial);
  76. hMyWearables[0] = iEntry | (iSerial « 16);
  77. break;
  78. }
  79.  
  80. C_BaseCombatWeapon* pEnt = (C_BaseCombatWeapon*)Interfaces::EntityList()->GetClientEntity(hMyWearables[0] & 0xFFF);
  81.  
  82. if (pEnt)
  83. {
  84. GloveFunctions::ApplyCustomSkin(pEnt, 0);
  85.  
  86. *pEnt->GetAccountID() = playerInfo.m_nXuidLow;
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement