#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
#pragma comment (lib,"user32.lib")
SAMPFUNCS *SF = new SAMPFUNCS();
static bool gun_rec = false;
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;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(0, 0xAA, 0), "SAMPFUNCS Plugin loaded.");
init = true;
}
if (SF->getGame()->isKeyPressed('R'))
{
if (!gun_rec)
{
keybd_event('E', 0, 0, 0);
Sleep(200);
keybd_event('E', 0, KEYEVENTF_KEYUP, 0);
}
else
{
keybd_event('Q', 0, 0, 0);
Sleep(200);
keybd_event('Q', 0, KEYEVENTF_KEYUP, 0);
}
gun_rec ^= true;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}