2021-09-20 08:41:40 -04:00
|
|
|
#include "pch.h"
|
|
|
|
#include "hook.h"
|
|
|
|
#include "cheatmenu.h"
|
|
|
|
#include "updater.h"
|
|
|
|
#include "menuinfo.h"
|
|
|
|
|
|
|
|
void MenuThread(void* param)
|
|
|
|
{
|
2021-09-21 04:00:26 -04:00
|
|
|
/*
|
|
|
|
Had to put this in place since some people put the folder in root
|
|
|
|
directory and the asi in modloader. Why??
|
|
|
|
|
|
|
|
TODO: Unlikely they'd even read the log so have to do something else
|
|
|
|
*/
|
2021-09-20 08:41:40 -04:00
|
|
|
if (!std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu")))
|
|
|
|
{
|
|
|
|
gLog << "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GTASA
|
|
|
|
Hook::ApplyMouseFix();
|
|
|
|
#endif
|
|
|
|
|
2021-09-21 04:00:26 -04:00
|
|
|
static bool bGameInit = false;
|
|
|
|
|
2021-09-20 08:41:40 -04:00
|
|
|
// Wait till game init
|
|
|
|
Events::initRwEvent += []
|
|
|
|
{
|
|
|
|
bGameInit = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
while (!bGameInit)
|
|
|
|
{
|
|
|
|
Sleep(1000);
|
|
|
|
}
|
|
|
|
|
2021-10-21 18:23:02 -04:00
|
|
|
#ifdef GTASA
|
2021-09-20 08:41:40 -04:00
|
|
|
/*
|
|
|
|
TODO: Find a better way
|
|
|
|
Since you could still name it something else
|
|
|
|
*/
|
|
|
|
if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi"))
|
|
|
|
{
|
|
|
|
MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
|
|
|
|
return;
|
|
|
|
}
|
2021-10-21 18:23:02 -04:00
|
|
|
CFastman92limitAdjuster::Init();
|
|
|
|
#endif
|
2021-09-20 08:41:40 -04:00
|
|
|
|
|
|
|
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: "
|
|
|
|
GITHUB_LINK "\n" << std::endl;
|
|
|
|
CheatMenu menu;
|
|
|
|
|
2021-09-21 04:00:26 -04:00
|
|
|
|
|
|
|
// Checking for updates once a day
|
2021-09-20 08:41:40 -04:00
|
|
|
time_t now = time(0);
|
|
|
|
struct tm tstruct = *localtime(&now);
|
2021-09-21 04:00:26 -04:00
|
|
|
int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0);
|
2021-09-20 08:41:40 -04:00
|
|
|
|
2021-09-21 04:00:26 -04:00
|
|
|
if (lastCheckDate != tstruct.tm_mday)
|
2021-09-20 08:41:40 -04:00
|
|
|
{
|
|
|
|
Updater::CheckForUpdate();
|
|
|
|
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
Sleep(5000);
|
|
|
|
|
|
|
|
if (Updater::m_State == UPDATER_CHECKING)
|
|
|
|
{
|
|
|
|
Updater::CheckForUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
|
|
|
{
|
|
|
|
if (nReason == DLL_PROCESS_ATTACH)
|
|
|
|
{
|
|
|
|
uint gameVersion = GetGameVersion();
|
2021-09-27 07:10:41 -04:00
|
|
|
|
2021-10-21 18:23:02 -04:00
|
|
|
if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN))
|
2021-09-20 08:41:40 -04:00
|
|
|
{
|
|
|
|
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-27 07:10:41 -04:00
|
|
|
#ifdef GTASA
|
2021-09-20 08:41:40 -04:00
|
|
|
MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR);
|
|
|
|
#elif GTAVC
|
|
|
|
MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR);
|
2021-10-21 18:23:02 -04:00
|
|
|
#else // GTA3
|
|
|
|
MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR);
|
2021-09-20 08:41:40 -04:00
|
|
|
#endif
|
2021-09-27 07:10:41 -04:00
|
|
|
}
|
2021-09-20 08:41:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|