Code:
#include <iostream>
#include <windows.h>
#include <fstream>
using namespace std;
string ALLP1 = "\n[AGP_Interface.AAGUIController]\n";
string ALLP2 = "AutoLoad=(MenuClassName=\"";
string ALLP3 = "\",bPreInitialize=True)\n";
string Caption = "Bot Loader v1.0 by Pvt.Hacks (Yuri)";
string Bot_Directory;
string Bot_Type;
string Bot_Copy_Loacation1 = "Setup\\";
string Bot_Copy_Loacation2;
string Check_exe;
string Check_ini;
string Check_Bot = "Setup\\";
string User_Back_Up;
char Americas_Army_Path[256];
char Bot_Name[256];
char Summon_Command[256];
int MBO;
bool newDeleteFile ( LPCSTR lpFileName )
{
OBJECT_ATTRIBUTES pObj;
UNICODE_STRING uFile;
WCHAR wFile[256];
swprintf ( wFile, L"\\??\\%S", lpFileName );
pRtlInitUnicodeString ( & uFile, wFile );
InitializeObjectAttributes ( & pObj, & uFile, OBJ_CASE_INSENSITIVE, 0, 0 );
if ( NT_SUCCESS ( pNtDeleteFile ( & pObj ) ) )
return true;
return false;
}
int main()
{
MBO = MessageBox ( 0, "Welcom to:\nBot Loader v1.0 by Pvt.Hacks (Yuri)\nDo you want to use this program?", Caption.c_str(), MB_YESNO | MB_ICONQUESTION );
if ( MBO == IDNO )
{
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
else
{
fstream Check_For_Setup ( "Setup\\Setup.txt", ios::in );
if ( Check_For_Setup.fail() )
{
Check_For_Setup.close();
MessageBox ( 0, "Couldn't lokate Setup.txt!", Caption.c_str(), MB_OK | MB_ICONERROR );
MBO = MessageBox ( 0, "Do you want a new Setup.txt?", Caption.c_str(), MB_YESNO | MB_ICONWARNING );
if ( MBO == IDYES )
{
CreateDirectory ( "Setup", 0 );
fstream Setup_Value ( "Setup\\Setup.txt", ios::out | ios::trunc );
Setup_Value.write ( "DO NOT RENAME THIS FILE, DELETE THIS FILE, REMOVE THIS FILE OR EDIT THIS FILE!\n", 79 );
Setup_Value.write ( "ONLY ENTER NUMBER 1, 2 AND 3 IN.\n", 33 );
Setup_Value.write ( "AND DO NOT RENAME THIS FOLDER , DELETE THIS FOLDER OR REMOVE THIS FOLDER!\n", 74 );
Setup_Value.write ( "USE BY NUMBER 1, TWO BACKSLASH'S ( \\\\ ) NOT ONE!\n\n", 50 );
Setup_Value.write ( "1. Enter here the path to your \"America's Army\" folder: \n\n", 58 );
Setup_Value.write ( "2. Enter here the name of your compiled Bot: \n\n", 47 );
Setup_Value.write ( "3. Enter here the name of the summon command of your Bot: \n\n\n\n", 62 );
Setup_Value.write ( "Examples:\n\n", 11 );
Setup_Value.write ( "1. Enter here the path to your \"America's Army\" folder: C:\\\\Program Files\\\\America's Army\n\n", 91 );
Setup_Value.write ( "2. Enter here the name of your compiled Bot: Bot.u\n\n", 52 );
Setup_Value.write ( "3. Enter here the name of summon string of your Bot: Bot.Load", 61 );
Setup_Value.close();
MessageBox ( 0, "Finished, new Setup.txt created, don't lose it again!", Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
else
{
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
}
else
{
Check_For_Setup.close();
fstream Setup ( "Setup\\Setup.txt", ios::in );
Setup.ignore ( 78 );
Setup.ignore();
Setup.ignore ( 32 );
Setup.ignore();
Setup.ignore ( 73 );
Setup.ignore();
Setup.ignore ( 48 );
Setup.ignore();
Setup.ignore();
Setup.ignore ( 56 );
Setup.getline ( Americas_Army_Path, 256 );
Setup.ignore();
Setup.ignore ( 45 );
Setup.getline ( Bot_Name, 256 );
Setup.ignore();
Setup.ignore ( 58 );
Setup.getline ( Summon_Command, 256 );
Setup.close();
if ( ! strcmp ( Americas_Army_Path, "" ) )
{
MessageBox ( 0, "No America's Army path found in Setup.txt!", Caption.c_str(), MB_OK | MB_ICONERROR );
MessageBox ( 0, "You need to enter the path to America's Army in Setup.txt.\n( Number 1. )" , Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
if ( ! strcmp ( Bot_Name, "" ) )
{
MessageBox ( 0, "No Bot Name found in Setup.txt!", Caption.c_str(), MB_OK | MB_ICONERROR );
MessageBox ( 0, "You need to enter the name of your bot in Setup.txt.\n( Number 2. )" , Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
if ( ! strcmp ( Summon_Command, "" ) )
{
MessageBox ( 0, "No summon command found in Setup.txt!", Caption.c_str(), MB_OK | MB_ICONERROR );
MessageBox ( 0, "You need to enter the summon command in Setup.txt.\n( Number 3. )" , Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
Check_exe = Americas_Army_Path;
Check_exe += "\\System\\ArmyOps.exe";
Check_ini = Americas_Army_Path;
Check_ini += "\\System\\User.ini";
fstream Check1_1 ( Check_exe.c_str(), ios::in );
fstream Check1_2 ( Check_ini.c_str(), ios::in );
if ( Check1_1.fail() || Check1_2.fail() )
{
Check1_1.close();
Check1_2.close();
MessageBox ( 0, "Couldn't lokate important files in your America's Army System folder!", Caption.c_str(), MB_OK | MB_ICONERROR );
MessageBox ( 0, "Check your Settings in Setup.txt if something isn't correct.\n( Number 1. )\nAnd check your files in your \"America's Army\\\\System\" folder." , Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
else
{
Check1_1.close();
Check1_2.close();
Check_Bot += Bot_Name;
fstream Check2_1 ( Check_Bot.c_str(), ios::in );
if ( Check2_1.fail() )
{
Check2_1.close();
MessageBox ( 0, "Couldn't lokate your Bot!", Caption.c_str(), MB_OK | MB_ICONERROR );
MessageBox ( 0, "Check your Settings in Setup.txt if something isn't correct.\n( Number 2. )\nAnd check if your Bot is located in the Setup folder." , Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
else
{
Check2_1.close();
if ( ! strstr ( Bot_Name, ".ukx" ) && ! strstr ( Bot_Name, ".aao" ) &&
! strstr ( Bot_Name, ".uvx" ) && ! strstr ( Bot_Name, ".uax" ) &&
! strstr ( Bot_Name, ".usx" ) && ! strstr ( Bot_Name, ".utx" ) &&
! strstr ( Bot_Name, ".u" ) )
{
MessageBox ( 0, "Your Bot has an invalid file type!", Caption.c_str(), MB_OK | MB_ICONERROR );
MessageBox ( 0, "Your Bot needs to have a valid file type.\n( .ukx, .aao, .uvx, .uax, .usx, .utx or .u )" , Caption.c_str(), MB_OK | MB_ICONWARNING );
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
else if ( strstr ( Bot_Name, ".ukx" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\Animations";
Bot_Type = "\\Animations\\";
}
else if ( strstr ( Bot_Name, ".aao" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\Maps";
Bot_Type = "\\Maps\\";
}
else if ( strstr ( Bot_Name, ".uvx" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\Saves";
Bot_Type = "\\Saves\\";
}
else if ( strstr ( Bot_Name, ".uax" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\Sounds";
Bot_Type = "\\Sounds\\";
}
else if ( strstr ( Bot_Name, ".usx" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\StaticMeshes";
Bot_Type = "\\StaticMeshes\\";
}
else if ( strstr ( Bot_Name, ".utx" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\Textures";
Bot_Type = "\\Textures\\";
}
else if ( strstr ( Bot_Name, ".u" ) )
{
Bot_Directory += Americas_Army_Path;
Bot_Directory += "\\System";
Bot_Type = "\\System\\";
}
MBO = MessageBox ( 0, "Ready to go!\nStart America's Army now?", Caption.c_str(), MB_YESNO | MB_ICONQUESTION );
if ( MBO == IDNO )
{
MessageBox ( 0, "Credits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
exit ( 0 );
}
else
{
Bot_Copy_Loacation1 += Bot_Name;
Bot_Copy_Loacation2 = Americas_Army_Path;
Bot_Copy_Loacation2 += Bot_Type;
Bot_Copy_Loacation2 += Bot_Name;
CreateDirectory ( Bot_Directory.c_str(), 0 );
CopyFile ( Bot_Copy_Loacation1.c_str(), Bot_Copy_Loacation2.c_str(), 0 );
User_Back_Up = Americas_Army_Path;
User_Back_Up += "\\System\\User Back Up.dat";
CopyFile ( Check_ini.c_str(), User_Back_Up.c_str(), 0 );
fstream Write_Auto_Load_Line ( Check_ini.c_str(), ios::out | ios::app );
Write_Auto_Load_Line.write ( ALLP1.c_str(), ALLP1.length() );
Write_Auto_Load_Line.write ( ALLP2.c_str(), ALLP2.length() );
Write_Auto_Load_Line.write ( Summon_Command, strlen ( Summon_Command ) );
Write_Auto_Load_Line.write ( ALLP3.c_str(), ALLP3.length() );
Write_Auto_Load_Line.close();
MessageBox ( 0, "Let's go!\nCredits goes to Yuri for creating this\nand HyPeR-X for the User.ini loading method.", Caption.c_str(), MB_OK | MB_ICONWARNING );
HWND hwnd;
ShellExecute ( hwnd, "open", Check_exe.c_str(), 0, 0, SW_SHOWNORMAL );
Sleep ( 20000 );
CopyFile ( User_Back_Up.c_str(), Check_ini.c_str(), 0 );
DeleteFile ( User_Back_Up.c_str() );
DeleteFile ( Bot_Copy_Loacation2.c_str() );// This is where I want to delete the file that is in use.
exit ( 0 );
}
}
}
}
}
}
I hope you can make it work, thanks.