Advertisement
djhonga2001

GTA V Snow

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