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->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, present); SF->getGame()->registerWndProcCallback(SFGame::HIGH_CB_PRIORITY, hookmsg); init = true; } if (SF->getGame()->isKeyPressed(0x7A)) { TwInit(TW_DIRECT3D9, SF->getRender()->getD3DDevice()); MenuState ^= true; if (MenuState) SF->getSAMP()->getMisc()->ToggleCursor(3, true); else { SF->getSAMP()->getMisc()->ToggleCursor(false); TwTerminate(); } } }
LRESULT CALLBACK MessageProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (TwEventWin(wnd, msg, wParam, lParam)) return 0; switch (msg) { case WM_CHAR: if (wParam == VK_ESCAPE) PostQuitMessage(0); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(wnd, msg, wParam, lParam); } } bool __stdcall hookmsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return MessageProc(hwnd, uMsg, wParam, lParam); }