2021-10-24 18:08:00 -04:00
# include "pch.h"
2021-10-25 10:03:27 -04:00
# include "cheatmenu.h"
2021-10-24 18:08:00 -04:00
# include "updater.h"
2022-01-13 08:57:08 -05:00
# include "version.h"
2021-09-20 08:41:40 -04:00
2021-10-25 10:03:27 -04:00
void MenuThread ( void * param )
2021-09-20 08:41:40 -04:00
{
2022-02-20 12:00:35 -05:00
/*
Wait for game init
// Sleep(3000);
Doing it like this doesn ' t prevent from attaching a debugger
*/
static bool gameStarted = false ;
Events : : processScriptsEvent + = [ ] {
gameStarted = true ;
} ;
2021-11-16 07:40:21 -05:00
2022-02-20 12:00:35 -05:00
while ( ! gameStarted )
{
Sleep ( 500 ) ;
}
2022-01-07 03:18:00 -05:00
/*
Had to put this in place since some people put the folder in root
directory and the asi in modloader . Why ? ?
*/
if ( ! std : : filesystem : : is_directory ( PLUGIN_PATH ( ( char * ) " CheatMenu " ) ) )
{
gLog < < " Error: CheatMenu folder not found. You need to put both \" CheatMenu.asi \" & \" CheatMenu \" folder in the same directory " < < std : : endl ;
2022-02-20 12:00:35 -05:00
MessageBox ( NULL , " CheatMenu folder not found. You need to put both \" CheatMenu.asi \" & \" CheatMenu \" folder in the same directory " , " CheatMenu " , MB_ICONERROR ) ;
2022-01-07 03:18:00 -05:00
return ;
}
2021-09-20 08:41:40 -04:00
2022-01-07 03:18:00 -05:00
/*
Need SilentPatch since all gta games have issues with mouse input
Implementing mouse fix is a headache anyway
*/
if ( ! GetModuleHandle ( BY_GAME ( " SilentPatchSA.asi " , " SilentPatchVC.asi " , " SilentPatchIII.asi " ) ) )
{
gLog < < " Error: SilentPatch not found. Please install it from here https://gtaforums.com/topic/669045-silentpatch/ " < < std : : endl ;
2022-02-20 12:00:35 -05:00
int msgID = MessageBox ( NULL , " SilentPatch not found. Do you want to install Silent Patch? (Game restart required) " , " CheatMenu " , MB_OKCANCEL | MB_DEFBUTTON1 ) ;
2021-09-20 08:41:40 -04:00
2022-01-07 03:18:00 -05:00
if ( msgID = = IDOK )
{
ShellExecute ( nullptr , " open " , " https://gtaforums.com/topic/669045-silentpatch/ " , nullptr , nullptr , SW_SHOWNORMAL ) ;
} ;
return ;
}
2021-09-20 08:41:40 -04:00
/*
TODO : Find a better way
Since you could still name it something else
*/
2022-01-13 08:57:08 -05:00
# ifdef GTASA
2022-01-07 03:18:00 -05:00
if ( GetModuleHandle ( " SAMP.dll " ) | | GetModuleHandle ( " SAMP.asi " ) )
{
gLog < < " Error: CheatMenu doesn't support SAMP " < < std : : endl ;
2022-02-20 12:00:35 -05:00
MessageBox ( NULL , " SAMP detected. Exiting CheatMenu. " , " CheatMenu " , MB_ICONERROR ) ;
2022-01-07 03:18:00 -05:00
return ;
}
CFastman92limitAdjuster : : Init ( ) ;
2022-01-13 08:57:08 -05:00
# elif GTAVC
if ( GetModuleHandle ( " vcmp-proxy.dll " ) | | GetModuleHandle ( " vcmp-proxy.asi " ) )
{
gLog < < " Error: CheatMenu doesn't support VCMP " < < std : : endl ;
2022-02-20 12:00:35 -05:00
MessageBox ( NULL , " VCMP detected. Exiting CheatMenu. " , " CheatMenu " , MB_ICONERROR ) ;
2022-01-13 08:57:08 -05:00
return ;
}
2021-10-21 18:23:02 -04:00
# endif
2021-09-20 08:41:40 -04:00
2022-01-07 03:18:00 -05:00
gLog < < " Starting... \n Version: " MENU_TITLE " \n Author: Grinch_ \n Discord: " DISCORD_INVITE " \n More Info: "
GITHUB_LINK " \n " < < std : : endl ;
2022-01-10 12:43:09 -05:00
2022-01-07 03:18:00 -05:00
CheatMenu menu ;
2021-09-20 08:41:40 -04:00
2022-01-07 03:18:00 -05:00
// Checking for updates once a day
2022-01-20 02:04:45 -05:00
SYSTEMTIME st ;
GetSystemTime ( & st ) ;
if ( gConfig . GetValue ( " config.update_date " , 0 ) ! = st . wDay )
2022-01-07 03:18:00 -05:00
{
Updater : : CheckUpdate ( ) ;
2022-01-20 02:04:45 -05:00
gConfig . SetValue ( " config.update_date " , st . wDay ) ;
2022-01-07 03:18:00 -05:00
}
2021-09-20 08:41:40 -04:00
2022-01-07 03:18:00 -05:00
while ( true )
{
Updater : : Process ( ) ;
2022-02-04 00:24:50 -05:00
Sleep ( 5000 ) ;
2022-01-07 03:18:00 -05:00
}
2021-09-20 08:41:40 -04:00
}
BOOL WINAPI DllMain ( HINSTANCE hDllHandle , DWORD nReason , LPVOID Reserved )
{
2022-01-07 03:18:00 -05:00
if ( nReason = = DLL_PROCESS_ATTACH )
{
2022-02-02 13:57:07 -05:00
uint gameVer = GetGameVersion ( ) ;
# ifdef GTASA
if ( gameVer = = GAME_10US_HOODLUM | | gameVer = = GAME_10US_COMPACT )
# else
if ( gameVer = = BY_GAME ( NULL , GAME_10EN , GAME_10EN ) )
# endif
2022-01-07 03:18:00 -05:00
{
CreateThread ( nullptr , NULL , ( LPTHREAD_START_ROUTINE ) & MenuThread , nullptr , NULL , nullptr ) ;
}
else
{
gLog < < " Error: Unknown game version. GTA " < < BY_GAME ( " SA v1.0 US Hoodlum " , " VC v1.0 EN " , " III v1.0 EN " ) < < " is required. " < < std : : endl ;
MessageBox ( HWND_DESKTOP , " Unknown game version. GTA " BY_GAME ( " SA v1.0 US Hoodlum " , " VC v1.0 EN " , " III v1.0 EN " ) " is required. " , " CheatMenu " , MB_ICONERROR ) ;
}
}
2021-09-20 08:41:40 -04:00
2022-01-07 03:18:00 -05:00
return TRUE ;
2021-09-20 08:41:40 -04:00
}