Advertisement
djhonga2001

snow test

Feb 2nd, 2016
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. bool featureXmas = false;
  2. bool featureXmasUpdated = false;
  3.  
  4. bool VehicleTracks = false;
  5. bool PedTracks = false;
  6. bool VehicleTrackDepth = false;
  7. bool PedTrackDepth = false;
  8.  
  9. // <Snow>
  10. void EnableTracks(bool tracksVehicle = false, bool tracksPeds = false, bool deepTracksVehicle = false, bool deepTracksPed = false)
  11. {
  12. static auto VAR_FeetSnowTracks_call = Memory::findPattern("\x80\x3D\x00\x00\x00\x00\x00\x48\x8B\xD9\x74\x37", "xx?????xxxxx");
  13.  
  14. if (!VAR_FeetSnowTracks_call)
  15. {
  16. return;
  17. }
  18. static auto VAR_FeetSnowTracks = VAR_FeetSnowTracks_call + (*(int32_t *)(VAR_FeetSnowTracks_call + 2)) + 7;
  19. //
  20. static auto VAR_VehicleSnowTracks_call = Memory::findPattern("\x40\x38\x3D\x00\x00\x00\x00\x48\x8B\x42\x20", "xxx????xxxx");
  21. if (!VAR_VehicleSnowTracks_call)
  22. {
  23. return;
  24. }
  25. static auto VAR_VehicleSnowTracks = VAR_VehicleSnowTracks_call + (*(int32_t *)(VAR_VehicleSnowTracks_call + 3)) + 7;
  26. //
  27.  
  28. VirtualProtect((void*)VAR_FeetSnowTracks, 1, PAGE_EXECUTE_READWRITE, nullptr);
  29. VirtualProtect((void*)VAR_VehicleSnowTracks, 1, PAGE_EXECUTE_READWRITE, nullptr);
  30.  
  31. // Enable/Disable Vehicle/Foot Snow tracks
  32. *(uint8_t *)VAR_FeetSnowTracks = tracksVehicle;
  33. *(uint8_t *)VAR_VehicleSnowTracks = tracksPeds;
  34.  
  35. // Switch for big/small tracks
  36. static auto vehicleTrackTypes = Memory::findPattern("\xB9\x00\x00\x00\x00\x84\xC0\x44\x0F\x44\xF1", "x????xxxxxx");
  37. if (!vehicleTrackTypes)
  38. {
  39. return;
  40. }
  41.  
  42. VirtualProtect((void*)vehicleTrackTypes, 1, PAGE_EXECUTE_READWRITE, nullptr);
  43. *(uint8_t *)(vehicleTrackTypes + 1) = deepTracksVehicle ? 0x13 : 0x14;
  44.  
  45. static auto pedTrackTypes = Memory::findPattern("\xB9\x00\x00\x00\x00\x84\xC0\x0F\x44\xD9\x48\x8B\x4F\x30", "x????xxxxxxxxx");
  46. if (!pedTrackTypes)
  47. {
  48. return;
  49. }
  50. VirtualProtect((void*)pedTrackTypes, 1, PAGE_EXECUTE_READWRITE, nullptr);
  51. *(uint8_t *)(pedTrackTypes + 1) = deepTracksPed ? 0x13 : 0x14;
  52. }
  53.  
  54. // Snow
  55. void EnableSnow(bool bEnable)
  56. {
  57. // Snow Address
  58. static auto addr = Memory::findPattern("\x74\x25\xB9\x00\x00\x00\x00\xE8\x00\x00\x00\x00", "xxx????x????");
  59.  
  60. // Outdated
  61. if (!addr)
  62. {
  63. notifyTop("Enabling Snow is not possbile on this version of GTA V", 5000, 0);
  64. featureXmas = false; // Disable snow
  65. return;
  66. }
  67.  
  68. // Original Memory
  69. static uint8_t original[20] = { 0 };
  70. static size_t num = sizeof(original);
  71.  
  72. // Initialize
  73. static bool bInitialized = false;
  74. if (!bInitialized)
  75. {
  76. bInitialized = true;
  77.  
  78. // Unprotect Memory
  79. VirtualProtect((void*)addr, num, PAGE_EXECUTE_READWRITE, nullptr);
  80.  
  81. // Copy original Memory
  82. memcpy(&original, (void*)addr, num);
  83. }
  84. if (bEnable)
  85. {
  86. // Weather
  87. GAMEPLAY::SET_WEATHER_TYPE_NOW_PERSIST("XMAS");
  88.  
  89. // NOP
  90. memset((void*)addr, 0x90, num);
  91.  
  92. // Tracks on
  93. EnableTracks(VehicleTracks, PedTracks, VehicleTrackDepth, PedTrackDepth);
  94.  
  95. // Notification
  96. notifyTop("Snow Enabled", 5000, 0);
  97. }
  98. else
  99. {
  100. // Weather
  101. GAMEPLAY::CLEAR_WEATHER_TYPE_PERSIST();
  102. GAMEPLAY::SET_WEATHER_TYPE_NOW("CLEAR");
  103.  
  104. // Reset original memory
  105. memcpy((void*)addr, &original, num);
  106.  
  107. // Tracks off
  108. EnableTracks();
  109.  
  110. // Notification
  111. notifyTop("Snow Disabled", 5000, 0);
  112. }
  113. }
  114.  
  115. //your menu
  116. { "Christmas", "XMAS", &featureXmas, &featureXmasUpdated },
  117.  
  118. //your ontick function
  119. if (featureXmasUpdated)
  120. {
  121. featureXmasUpdated = false;
  122. if (featureXmas) {
  123.  
  124. VehicleTracks = featureXmas;
  125. PedTracks = featureXmas;
  126. VehicleTrackDepth = featureXmas;
  127. PedTrackDepth = featureXmas;
  128. EnableSnow(featureXmas);
  129. }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement