2021-10-24 18:08:00 -04:00
# include "pch.h"
2021-10-25 10:03:27 -04:00
# include "hook.h"
# include "cheatmenu.h"
2021-10-24 18:08:00 -04:00
# include "updater.h"
2021-10-25 10:03:27 -04:00
# include "menuinfo.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
{
2021-11-16 07:40:21 -05:00
static bool bGameInit = false ;
// Wait till game init
Events : : initRwEvent + = [ ]
{
bGameInit = true ;
} ;
while ( ! bGameInit )
{
Sleep ( 1000 ) ;
}
2021-10-25 10:03:27 -04: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 " ) ) )
{
2021-11-17 03:35:12 -05:00
gLog < < " Error: CheatMenu folder not found. You need to put both \" CheatMenu.asi \" & \" CheatMenu \" folder in the same directory " < < std : : endl ;
2021-11-16 07:40:21 -05:00
MessageBox ( RsGlobal . ps - > window , " CheatMenu folder not found. You need to put both \" CheatMenu.asi \" & \" CheatMenu \" folder in the same directory " , " CheatMenu " , MB_ICONERROR ) ;
2021-10-25 10:03:27 -04:00
return ;
}
2021-09-20 08:41:40 -04:00
2021-11-17 03:35:12 -05:00
/*
Need SilentPatch since all gta games have issues with mouse input
Implementing mouse fix is a headache anyway
*/
2021-11-16 07:40:21 -05:00
if ( ! GetModuleHandle ( BY_GAME ( " SilentPatchSA.asi " , " SilentPatchVC.asi " , " SilentPatchIII.asi " ) ) )
2021-10-25 10:03:27 -04:00
{
2021-11-17 03:35:12 -05:00
gLog < < " Error: SilentPatch not found. Please install it from here https://gtaforums.com/topic/669045-silentpatch/ " < < std : : endl ;
2021-11-16 07:40:21 -05:00
int msgID = MessageBox ( RsGlobal . ps - > window , " 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
2021-11-16 07:40:21 -05:00
if ( msgID = = IDOK )
{
ShellExecute ( nullptr , " open " , " https://gtaforums.com/topic/669045-silentpatch/ " , nullptr , nullptr , SW_SHOWNORMAL ) ;
} ;
return ;
2021-10-25 10:03:27 -04:00
}
2021-09-20 08:41:40 -04:00
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
*/
2021-10-25 10:03:27 -04:00
if ( GetModuleHandle ( " SAMP.dll " ) | | GetModuleHandle ( " SAMP.asi " ) )
{
2021-11-17 03:35:12 -05:00
gLog < < " Error: CheatMenu doesn't support SAMP " < < std : : endl ;
2021-10-25 10:03:27 -04:00
MessageBox ( RsGlobal . ps - > window , " SAMP detected. Exiting CheatMenu. " , " CheatMenu " , MB_ICONERROR ) ;
return ;
}
CFastman92limitAdjuster : : Init ( ) ;
2021-10-21 18:23:02 -04:00
# endif
2021-09-20 08:41:40 -04:00
2021-10-25 10:03:27 -04:00
gLog < < " Starting... \n Version: " MENU_TITLE " \n Author: Grinch_ \n Discord: " DISCORD_INVITE " \n More Info: "
GITHUB_LINK " \n " < < std : : endl ;
CheatMenu menu ;
2021-09-20 08:41:40 -04:00
2021-09-21 04:00:26 -04:00
2021-10-25 10:03:27 -04:00
// Checking for updates once a day
time_t now = time ( 0 ) ;
struct tm tstruct = * localtime ( & now ) ;
int lastCheckDate = gConfig . GetValue ( " config.last_update_checked " , 0 ) ;
2021-09-20 08:41:40 -04:00
2021-10-25 10:03:27 -04:00
if ( lastCheckDate ! = tstruct . tm_mday )
{
Updater : : CheckForUpdate ( ) ;
gConfig . SetValue ( " config.last_update_checked " , tstruct . tm_mday ) ;
}
2021-09-20 08:41:40 -04:00
2021-10-25 10:03:27 -04:00
while ( true )
{
Sleep ( 5000 ) ;
if ( Updater : : m_State = = UPDATER_CHECKING )
{
Updater : : CheckForUpdate ( ) ;
}
}
2021-09-20 08:41:40 -04:00
}
BOOL WINAPI DllMain ( HINSTANCE hDllHandle , DWORD nReason , LPVOID Reserved )
{
2021-10-25 10:03:27 -04:00
if ( nReason = = DLL_PROCESS_ATTACH )
{
uint gameVersion = GetGameVersion ( ) ;
if ( gameVersion = = BY_GAME ( GAME_10US_HOODLUM , GAME_10EN , GAME_10EN ) )
{
CreateThread ( nullptr , NULL , ( LPTHREAD_START_ROUTINE ) & MenuThread , nullptr , NULL , nullptr ) ;
}
else
{
2021-11-17 03:35:12 -05:00
gLog < < " Error: Unknown game version. GTA " < < BY_GAME ( " SA v1.0 US Hoodlum " , " GTA VC v1.0 EN " , " GTA III v1.0 EN " ) < < " is required. " < < std : : endl ;
2021-09-27 07:10:41 -04:00
# ifdef GTASA
2021-11-17 03:35:12 -05:00
MessageBox ( HWND_DESKTOP , " Unknown game version. GTA SA v1.0 US Hoodlum is required. " , " CheatMenu " , MB_ICONERROR ) ;
2021-09-20 08:41:40 -04:00
# elif GTAVC
2021-10-25 10:03:27 -04:00
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
2021-10-25 10:03:27 -04:00
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-10-25 10:03:27 -04:00
}
}
2021-09-20 08:41:40 -04:00
2021-10-25 10:03:27 -04:00
return TRUE ;
2021-09-20 08:41:40 -04:00
}