Grisha2307
Новичок
- 18
- 4
Помогите пожалуйста, при получении любого пакета игра закрывается.
код:
#include <Windows.h>
#include "main.h"
#include <string>
#include <thread>
#include <chrono>
#include "fstream"
using namespace std;
SAMPFUNCS* SF = new SAMPFUNCS();
void __stdcall initScript(string);
void logSF(char);
static bool isActive = false;
static bool CALLBACK incomingPacket(stRakNetHookParams *params) {
return true;
}
static void __stdcall mainloop() {
static bool initialized = false;
if (!initialized) {
if (GAME && GAME->GetSystemState() == eSystemState::GS_PLAYING_GAME && SF->getSAMP()->IsInitialized()) {
initialized = true;
SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_PACKET, incomingPacket);
SF->getSAMP()->registerChatCommand("stallSkip", initScript);
}
}
}
void __stdcall initScript(string) {
string text;
int color;
if (!isActive) {
color = D3DCOLOR_ARGB(255, 0, 255, 0);
text = "[******] Активирован";
} else {
color = D3DCOLOR_ARGB(255, 255, 0, 0);
text = "[******] Деактивирован";
}
isActive ^= true;
SF->getSAMP()->getChat()->AddChatMessage(color, "%s", text);
}
void logSF(char text) {
ofstream outputFile("SAMPFUNCS/logs.txt");
if (outputFile.is_open()) {
outputFile << text;
outputFile.close();
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved) {
if (dwReasonForCall == DLL_PROCESS_ATTACH)
SF->initPlugin(mainloop, hModule);
return TRUE;
}