Advertisement
djhonga2001

Untitled

Jun 10th, 2016
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // <Snow>
  2. bool featureXmas = false;
  3. bool featureXmasUpdated = false;
  4.  
  5. void EnableSnow(bool bEnable)
  6. {
  7. auto SnowPtn = Memory::findAOB("74 25 B9 40 ? ? ? E8 ? ? C4 FF");
  8. char * SnowPtr = reinterpret_cast<char*>(SnowPtn);
  9. static void * nop_location = SnowPtr;
  10.  
  11. // Original Memory
  12. static uint8_t original1[20] = { 0 };
  13.  
  14. // Initialize
  15. static bool bInitialized = false;
  16. if (!bInitialized)
  17. {
  18. if (nop_location != nullptr)
  19. {
  20. // Unprotect Memory
  21. unsigned long OldProtection;
  22. VirtualProtect(nop_location, 20, PAGE_EXECUTE_READWRITE, &OldProtection);
  23.  
  24. // Backup original Memory
  25. memcpy(&original1, nop_location, 20);
  26.  
  27. // Reprotect Memory
  28. VirtualProtect(nop_location, 20, OldProtection, NULL);
  29.  
  30. bInitialized = true;
  31. }
  32. else
  33. {
  34. notifyTop("Enabling Snow is not supported on this version of GTA V", 5000, 0);
  35. return;
  36. }
  37.  
  38. }
  39.  
  40. if (bEnable) {
  41. // nop bytes
  42. if (nop_location != nullptr)
  43. memset(nop_location, 0x90, 20);
  44.  
  45. // Set Xmas Weather
  46. GAMEPLAY::SET_WEATHER_TYPE_NOW_PERSIST("XMAS");
  47.  
  48. // enable Tracks
  49. GRAPHICS::_SET_FORCE_PED_FOOTSTEPS_TRACKS(1);
  50. GRAPHICS::_SET_FORCE_VEHICLE_TRAILS(1);
  51. }
  52.  
  53. else {
  54.  
  55. // Unprotect Memory
  56. unsigned long OldProtection;
  57. VirtualProtect(nop_location, 20, PAGE_EXECUTE_READWRITE, &OldProtection);
  58.  
  59. // Restore original memory
  60. memcpy(nop_location, &original1, 20);
  61.  
  62. // Reprotect Memory
  63. VirtualProtect(nop_location, 20, OldProtection, NULL);
  64.  
  65. // Set Clear Weather
  66. GAMEPLAY::SET_WEATHER_TYPE_NOW_PERSIST("CLEAR");
  67.  
  68. // remove Tracks
  69. GRAPHICS::_SET_FORCE_PED_FOOTSTEPS_TRACKS(0);
  70. GRAPHICS::_SET_FORCE_VEHICLE_TRAILS(0);
  71. }
  72. }
  73. // < /Snow>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement