#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
#include "SFAPI\SFRakNet.h"
#include <tchar.h>
#include <fstream>
#include <stdlib.h>
#include <iostream>
#include <Shlwapi.h>
#include "qwe\main.h"
#pragma comment(lib, "shlwapi.lib")
using namespace std;
SAMPFUNCS *SF = new SAMPFUNCS();
int *a = nullptr;
bool CALLBACK irpc(stRakNetHookParams *params)
{
if (params->packetId == ScriptRPCEnumeration::RPC_ScrClientMessage) // id: 93 thanks for MISTER_GONWIK
{
D3DCOLOR color = -1;
int length = 0;
char message[144]{ 0 };
params->bitStream->Read(color);
params->bitStream->Read(length);
params->bitStream->Read(message, length);
//sss[len] = '\0';
if (strcmp(string(message).c_str(), " ") == 0)
return false;
else
{
//SF->getSAMP()->getChat()->AddChatMessage(555555, "%s", string(message).c_str());
//fout << "\n" << string(message).c_str();
}
}
return true;
}
void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{
if (GAME == nullptr)
return;
if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
return;
if (!SF->getSAMP()->IsInitialized())
return;
init = true;
char meow[MAX_PATH];
GetCurrentDirectory(sizeof(meow), meow);
if (PathFileExists(strcat(meow, "/yiffme")))
{
ofstream fout("yiffme", ios::app);
*a = reinterpret_cast<int>(&fout);
SF->getSAMP()->getChat()->AddChatMessage(555555, "file exist");
}
else
SF->getSAMP()->getChat()->AddChatMessage(555555, "file doesnt exist");
fout << "\nsession started";
SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_RPC, irpc);
}
}