#pragma comment(lib, "user32.lib")
#include <windows.h>
#include <assert.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
SAMPFUNCS *SF = new SAMPFUNCS();
using namespace std;
string GetDir()
{
char MainDir[256];
GetCurrentDirectory(256, MainDir);
string Result = MainDir;
return Result;
}
void CreateResultFile(char * Organization, char * Subdivision, char * Data, char * Time, char * FileText)
{
string MainDirectory = GetDir();
MainDirectory += "\\SAMPFUNCS\\";
CreateDirectory(string(MainDirectory + "TestScript").c_str(), NULL);
CreateDirectory(string(MainDirectory + "TestScript\\MainTest").c_str(), NULL);
CreateDirectory(string(MainDirectory + "TestScript\\MainTest\\" + Organization).c_str(), NULL);
CreateDirectory(string(MainDirectory + "TestScript\\MainTest\\" + Organization + "\\" + Subdivision + "\\").c_str(), NULL);
CreateDirectory(string(MainDirectory + "TestScript\\MainTest\\" + Organization + "\\" + Subdivision + "\\" + Data + "\\").c_str(), NULL);
FILE *pFile = fopen(string(MainDirectory + "TestScript\\MainTest\\" + Organization + "\\" + Subdivision + "\\" + Data + "\\" + Time + ".ini").c_str(), "w");
fwrite(FileText, strlen(FileText), 1, pFile);
fclose(pFile);
}
void CALLBACK loop()
{
static bool init = false;
if (!init)
{
if (GAME == nullptr || GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME || !SF->getSAMP()->IsInitialized()) return;
CreateResultFile("Proba", "Testing", "03.07.2016", "13 20", "Write in file is successful");
init = true;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
if (dwReasonForCall == DLL_PROCESS_ATTACH) return SF->initPlugin(loop, hModule);
return TRUE;
}