Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
  2.  
  3. #include <windows.h>
  4. #include <string>
  5. #include <assert.h>
  6. #include <process.h>
  7.  
  8. #include "SAMPFUNCS_API.h"
  9. #include "game_api\game_api.h"
  10.  
  11. SAMPFUNCS *SF = new SAMPFUNCS();
  12.  
  13. stFontInfo *pFont;
  14. DWORD endTime;
  15.  
  16. bool CALLBACK Present(CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride,
  17.     CONST RGNDATA *pDirtyRegion)
  18. {
  19.     if (SUCCEEDED(SF->getRender()->BeginRender()))
  20.     {
  21.         char text[32] = "нога";
  22.         if (GetTickCount() < endTime)
  23.             sprintf(text, "time: %d", (endTime - GetTickCount()) / 1000 + 1); // + 1, чтобы начиналось с пяти и заканчивалось на единице
  24.  
  25.         pFont->Print(text, D3DCOLOR_ARGB(255, 255, 255, 0), 500, 500, false);
  26.         SF->getRender()->EndRender();
  27.     }
  28.     return true;
  29. };
  30.  
  31. void CALLBACK timer(std::string)
  32. {
  33.     endTime = GetTickCount() + 5000; // 5 сек
  34. }
  35.  
  36. void CALLBACK mainloop()
  37. {
  38.     static bool init = false;
  39.     if (!init)
  40.     {
  41.         if (GAME == nullptr)
  42.             return;
  43.         if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
  44.             return;
  45.         if (!SF->getSAMP()->IsInitialized())
  46.             return;
  47.  
  48.         SF->getSAMP()->registerChatCommand("timer", timer);
  49.         pFont = SF->getRender()->CreateNewFont("Tahoma", 12, FCR_BORDER);
  50.         SF->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present);
  51.  
  52.         init = true;
  53.     }
  54. }
  55.  
  56. BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
  57. {
  58.     switch (dwReasonForCall)
  59.     {
  60.     case DLL_PROCESS_ATTACH:
  61.         SF->initPlugin(mainloop, hModule);
  62.         break;
  63.     case DLL_THREAD_ATTACH:
  64.     case DLL_THREAD_DETACH:
  65.     case DLL_PROCESS_DETACH:
  66.         break;
  67.     }
  68.     return TRUE;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement