Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. #include "InventoryChanger.h"
  2. #include <vector>
  3.  
  4. void AddItem(CMsgSOCacheSubscribed::SubscribedType* Object, int index, int itemDefIndex, int rarity, int paintKit, int seed, float wear, std::string name, int quality)
  5. {
  6. CSOEconItem Skin;
  7.  
  8. Skin.set_id(20000 + index);
  9. Skin.set_account_id(Interfaces::SteamUser()->GetSteamID().GetAccountID());
  10. Skin.set_def_index(itemDefIndex);
  11. Skin.set_inventory(20000 + index);
  12. Skin.set_origin(24);
  13. Skin.set_quantity(1);
  14. Skin.set_level(1);
  15. Skin.set_style(0);
  16. Skin.set_flags(0);
  17. Skin.set_in_use(false);
  18. Skin.set_original_id(0);
  19. Skin.set_rarity(rarity);
  20. Skin.set_quality(quality);
  21.  
  22. if (name.size() > 0)
  23. Skin.set_custom_name(name.data());
  24.  
  25. // Paint Kit
  26. auto PaintKitAttribute = Skin.add_attribute();
  27. float PaintKitAttributeValue = (float)paintKit;
  28.  
  29. PaintKitAttribute->set_def_index(6);
  30.  
  31. PaintKitAttribute->set_value_bytes(&PaintKitAttributeValue, 4);
  32.  
  33. // Paint Seed
  34. auto SeedAttribute = Skin.add_attribute();
  35. float SeedAttributeValue = (float)seed;
  36.  
  37. SeedAttribute->set_def_index(7);
  38.  
  39. SeedAttribute->set_value_bytes(&SeedAttributeValue, 4);
  40.  
  41. // Paint Wear
  42. auto WearAttribute = Skin.add_attribute();
  43. float WearAttributeValue = wear;
  44.  
  45. WearAttribute->set_def_index(8);
  46.  
  47. WearAttribute->set_value_bytes(&WearAttributeValue, 4);
  48.  
  49. // Stickers
  50. for (int j = 0; j < 4; j++)
  51. {
  52. // Sticker Kit
  53. CSOEconItemAttribute* StickerKitAttribute = Skin.add_attribute();
  54. uint32_t StickerKitAttributeValue = 0;
  55.  
  56. StickerKitAttribute->set_def_index(113 + 4 * j);
  57.  
  58. StickerKitAttribute->set_value_bytes(&StickerKitAttributeValue, 4);
  59.  
  60. // Sticker Wear
  61. CSOEconItemAttribute* StickerWearAttribute = Skin.add_attribute();
  62. float StickerWearAttributeValue = 0.001f;
  63.  
  64. StickerWearAttribute->set_def_index(114 + 4 * j);
  65.  
  66. StickerWearAttribute->set_value_bytes(&StickerWearAttributeValue, 4);
  67.  
  68. // Sticker Scale
  69. CSOEconItemAttribute* StickerScaleAttribute = Skin.add_attribute();
  70. float StickerScaleAttributeValue = 1.f;
  71.  
  72. StickerScaleAttribute->set_def_index(115 + 4 * j);
  73.  
  74. StickerScaleAttribute->set_value_bytes(&StickerScaleAttributeValue, 4);
  75.  
  76. // Sticker Rotation
  77. CSOEconItemAttribute* StickerRotationAttribute = Skin.add_attribute();
  78. float StickerRotationAttributeValue = 0.f;
  79.  
  80. StickerRotationAttribute->set_def_index(116 + 4 * j);
  81.  
  82. StickerRotationAttribute->set_value_bytes(&StickerRotationAttributeValue, 4);
  83. }
  84.  
  85. Object->add_object_data(Skin.SerializeAsString());
  86. }
  87.  
  88. void CInventoryChanger::PostRetrieveMessage(uint32_t* punMsgType, void* pubDest, uint32_t cubDest, uint32_t* pcubMsgSize)
  89. {
  90. if (!Settings::InventoryChanger::enabled)
  91. return;
  92.  
  93. uint32_t MessageType = *punMsgType & 0x7FFFFFFF;
  94.  
  95. if (MessageType != k_EMsgGCClientWelcome)
  96. return;
  97. CMsgClientWelcome Message;
  98.  
  99. try
  100. {
  101. if (!Message.ParsePartialFromArray((void*)((DWORD)pubDest + 8), *pcubMsgSize - 8))
  102. return;
  103. }
  104. catch (...)
  105. {
  106. return;
  107. }
  108.  
  109. if (Message.outofdate_subscribed_caches_size() <= 0)
  110. return;
  111.  
  112. CMsgSOCacheSubscribed* Cache = Message.mutable_outofdate_subscribed_caches(0);
  113.  
  114. for (int i = 0; i < Cache->objects_size(); i++)
  115. {
  116. CMsgSOCacheSubscribed::SubscribedType* Object = Cache->mutable_objects(i);
  117.  
  118. if (!Object->has_type_id())
  119. continue;
  120.  
  121. if (Object->type_id() == 1) {
  122. for (int j = 0; j < Object->object_data_size(); j++)
  123. {
  124. std::string* ObjectData = Object->mutable_object_data(j);
  125.  
  126. CSOEconItem Item;
  127.  
  128. if (!Item.ParseFromArray((void*)const_cast<char*>(ObjectData->data()), ObjectData->size()))
  129. continue;
  130.  
  131. if (Item.equipped_state_size() <= 0)
  132. continue;
  133. }
  134.  
  135. AddItem(Object, 1, WEAPON_AK47, 6, 600, 0, 0.001f, "", 4);
  136. AddItem(Object, 2, WEAPON_KNIFE_KARAMBIT, 6, 576, 38, 0.001f, "", 3);
  137. AddItem(Object, 3, WEAPON_KNIFE_BAYONET, 6, 419, 38, 0.001f, "", 3);
  138. AddItem(Object, 4, WEAPON_KNIFE_KARAMBIT, 6, 409, 38, 0.001f, "", 3);
  139. AddItem(Object, 5, WEAPON_KNIFE_KARAMBIT, 6, 409, 38, 0.001f, "", 3);
  140. AddItem(Object, 4, WEAPON_KNIFE_FLIP, 6, 572, 38, 0.001f, "", 3);
  141.  
  142.  
  143.  
  144. ApplyMedals(Object);
  145. }
  146. }
  147.  
  148. if ((uint32_t)Message.ByteSize() <= cubDest - 8)
  149. {
  150. Message.SerializeToArray((void*)((DWORD)pubDest + 8), Message.ByteSize());
  151.  
  152. *pcubMsgSize = Message.ByteSize() + 8;
  153. }
  154. }
  155.  
  156. bool CInventoryChanger::PreSendMessage(uint32_t &unMsgType, void* pubData, uint32_t &cubData)
  157. {
  158. if (!Settings::InventoryChanger::enabled)
  159. return true;
  160.  
  161. uint32_t MessageType = unMsgType & 0x7FFFFFFF;
  162.  
  163. return true;
  164. }
  165.  
  166. void CInventoryChanger::ApplyMedals(CMsgSOCacheSubscribed::SubscribedType* pInventoryCacheObject)
  167. {
  168. CSOEconItem Medal;
  169.  
  170. Medal.set_account_id(Interfaces::SteamUser()->GetSteamID().GetAccountID());
  171. Medal.set_origin(9);
  172. Medal.set_rarity(6);
  173. Medal.set_quantity(1);
  174. Medal.set_quality(4);
  175. Medal.set_level(1);
  176.  
  177. CSOEconItemAttribute* TimeAcquiredAttribute = Medal.add_attribute();
  178. uint32_t TimeAcquiredAttributeValue = 0;
  179.  
  180. TimeAcquiredAttribute->set_def_index(222);
  181.  
  182. TimeAcquiredAttribute->set_value_bytes(&TimeAcquiredAttributeValue, 4);
  183.  
  184. int i = 10000;
  185. for (uint32_t MedalIndex : Settings::InventoryChanger::medals)
  186. {
  187. Medal.set_def_index(MedalIndex);
  188. Medal.set_inventory(i);
  189. Medal.set_id(i);
  190.  
  191. pInventoryCacheObject->add_object_data(Medal.SerializeAsString());
  192.  
  193. i++;
  194. }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement