Advertisement
djhonga2001

GTA-V tp to mission objective - Gir

Jul 19th, 2015
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. //blip is already defined in types.h
  2. //redefine that blip to blip2
  3. extern MODULEINFO g_MainModuleInfo;//goes in header
  4. MODULEINFO g_MainModuleInfo = { 0 };//goes in main.cpp
  5.  
  6.  
  7.   if (!GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &g_MainModuleInfo, sizeof(g_MainModuleInfo))) {
  8.    write_text_to_log_file("Unable to bypass model request block");
  9.   }
  10. //goes in dll_process_attach in main
  11.  
  12.  
  13. DWORD64 g_dwThreadCollectionPtr = 0;
  14. BlipList* g_blipList;
  15. rage::pgPtrCollection<GtaThread>* GetGtaThreadCollection() {
  16.     DWORD64 blipCollectionSignature = Pattern::Scan(g_MainModuleInfo, "4C 8D 05 ? ? ? ? 0F B7 C1");
  17.     g_blipList = (BlipList*)(blipCollectionSignature + *(DWORD*)(blipCollectionSignature + 3) + 7);
  18.  
  19.     return (rage::pgPtrCollection<GtaThread>*) g_dwThreadCollectionPtr;
  20. }
  21.  
  22. GtaThread_VTable gGtaThreadOriginal;
  23. GtaThread_VTable gGtaThreadNew;
  24.  
  25. bool ThreadCollection() {
  26.     rage::pgPtrCollection<GtaThread>* threadCollection = GetGtaThreadCollection();
  27.     if (!threadCollection) {
  28.         return false;
  29.     }
  30.  
  31.     for (UINT16 i = 0; i < threadCollection->count(); i++) {
  32.         GtaThread* pThread = threadCollection->at(i);
  33.  
  34.         if (!pThread)
  35.             continue;
  36.  
  37.         //s0biet originally had some junk thread that was called for like 2 seconds then died. This thread is better.
  38.         if (pThread->GetContext()->ScriptHash != 0x5700179C) {
  39.             continue;
  40.         }
  41.  
  42.         // Now what? We need to find a target thread and hook it's "Tick" function
  43.         if (gGtaThreadOriginal.Deconstructor == NULL) {
  44.             memcpy(&gGtaThreadOriginal, (DWORD64*)((DWORD64*)pThread)[0], sizeof(gGtaThreadOriginal)); //Create a backup of the original table so we can call the original functions from our hook.
  45.             memcpy(&gGtaThreadNew, &gGtaThreadOriginal, sizeof(GtaThread_VTable)); //Construct our VMT replacement table.
  46.         }
  47.  
  48.         if (((DWORD64*)pThread)[0] != (DWORD64)&gGtaThreadNew) { //If the table is not VMT Hooked.
  49.             write_text_to_log_file("Hooking thread: " + pThread->GetContext()->ThreadId);
  50.             write_text_to_log_file("Hash: " + pThread->GetContext()->ScriptHash);
  51.             ((DWORD64*)pThread)[0] = (DWORD64)&gGtaThreadNew; //Replace the VMT pointer with a pointer to our new VMT.
  52.             write_text_to_log_file("Hooked thread: " + pThread->GetContext()->ThreadId);
  53.             write_text_to_log_file("Hash: " + pThread->GetContext()->ScriptHash);
  54.             return true;
  55.         }
  56.     }
  57.     return false;
  58. }
  59.  
  60. //Below code goes into the case label
  61.  
  62.  
  63.         ThreadCollection();
  64.         for (int i = 0; i <= 1000; i++)
  65.         {
  66.             Blip* blip = g_blipList->m_Blips[i].m_pBlip;
  67.             if (blip)
  68.             {
  69.                 if ((blip->dwColor == BLIPCOLOR_MISSION && blip->iIcon == BLIP_CIRCLE) ||
  70.                     (blip->dwColor == BLIPCOLOR_YELLOWMISSION && blip->iIcon == BLIP_CIRCLE) ||
  71.                     (blip->dwColor == BLIPCOLOR_NONE && blip->iIcon == BLIP_RACEFLAG) ||
  72.                     (blip->dwColor == BLIPCOLOR_GREEN && blip->iIcon == BLIP_CIRCLE) ||
  73.                     (blip->iIcon == BLIP_SPECIALCRATE))
  74.                 {
  75.                     Entity e = PLAYER::PLAYER_PED_ID();
  76.                     if (PED::IS_PED_IN_ANY_VEHICLE(e, 0))
  77.                         e = PED::GET_VEHICLE_PED_IS_USING(e);
  78.                     NETWORK::NETWORK_REQUEST_CONTROL_OF_ENTITY(e);
  79.                     ENTITY::SET_ENTITY_COORDS_NO_OFFSET(e, blip->x, blip->y, blip->z, FALSE, FALSE, TRUE);
  80.                     break; //During a race there's sometimes 2 yellow markers. We want the first one.
  81.                 }
  82.             }
  83.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement