Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void checkForUpdate() {
- remove("crashes.delete");
- HINTERNET hNet, hNetFile;
- hNet = InternetOpenA("Mozilla/5.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
- if(hNet == NULL)
- return;
- hNetFile = InternetOpenUrlA(hNet, "https://raw.githubusercontent.com/Whitetigerswt/gtasa_crashfix/master/LatestVersion.txt", 0, 0, 0, 0);
- if(hNetFile == NULL)
- return;
- char szLatestVersion[256];
- DWORD dwBytesRead = 0;
- do {
- InternetReadFile(hNetFile, (LPVOID)szLatestVersion, 256, &dwBytesRead);
- } while(dwBytesRead > 0);
- float version;
- char* url = new char[200];
- sscanf_s (szLatestVersion, "%f %s", &version, url);
- if(version > VERSION) {
- DeleteUrlCacheEntry(url);
- char currentDir[MAX_PATH + 15];
- GetCurrentDirectory( MAX_PATH, currentDir );
- strcat_s(currentDir, "\\crashes.delete_");
- DeleteFile(currentDir);
- HRESULT hr = URLDownloadToFile(NULL, url, currentDir, 0, NULL);
- if(SUCCEEDED(hr)) {
- char currentMod[MAX_PATH + 15];
- GetModuleFileName(g_hMod, currentMod, MAX_PATH+15);
- currentMod[strlen(currentMod)] = '\0';
- rename(currentMod, "crashes.delete");
- rename(currentDir, "crashes.asi");
- LoadLibrary("crashes.asi");
- FreeLibraryAndExitThread(g_hMod, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment