Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.40 KB | None | 0 0
  1. #include <windows.h>
  2. #include <string>
  3. #include <assert.h>
  4. #include <process.h>
  5. #include <time.h>
  6.  
  7. #include "SAMPFUNCS_API.h"
  8. #include "game_api\game_api.h"
  9.  
  10. SAMPFUNCS *SF = new SAMPFUNCS();
  11. stFontInfo *pFont;
  12. BOOL ti_status = TRUE;
  13.  
  14. const std::string currentDateTime() {
  15.     time_t     now = time(0);
  16.     struct tm  tstruct;
  17.     char       buf[80];
  18.     tstruct = *localtime(&now);
  19.     strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct);
  20.     return buf;
  21. }
  22.  
  23. void CALLBACK cmd_ti(std::string) {
  24.     ti_status = !ti_status;
  25. }
  26.  
  27. bool CALLBACK Present(CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride,
  28.     CONST RGNDATA *pDirtyRegion)
  29. {
  30.     if (SUCCEEDED(SF->getRender()->BeginRender()))
  31.     {
  32.         if (ti_status == TRUE) {
  33.             if (SF->getGame()->isGTAMenuActive() == FALSE) {
  34.  
  35.                 std::string curtime = currentDateTime();
  36.                 std::string curplayer = SF->getSAMP()->getPlayers()->szLocalPlayerName;
  37.                 int curid = SF->getSAMP()->getPlayers()->sLocalPlayerID;
  38.                 SF->getSAMP()->getInfo()->UpdateScoreAndPing();
  39.                 int curlvl = SF->getSAMP()->getPlayers()->iLocalPlayerScore;
  40.                 int curpng = SF->getSAMP()->getPlayers()->iLocalPlayerPing;
  41.  
  42.                 std::string allinf = "Локальное время: " + curtime + "\r\nID: " + std::to_string(curid) + "\r\nНик: " + curplayer + "\r\nУровень: " + std::to_string(curlvl) + "\r\nПинг: " + std::to_string(curpng);
  43.  
  44.                 pFont->Print(allinf.c_str(), D3DCOLOR_ARGB(255, 000, 255, 000), 50, 330, false);
  45.  
  46.             }
  47.         }
  48.         SF->getRender()->EndRender();
  49.     };
  50.  
  51.     return true;
  52. };
  53.  
  54. void CALLBACK mainloop()
  55. {
  56.     static bool init = false;
  57.     if (!init)
  58.     {
  59.         if (GAME == nullptr)
  60.             return;
  61.         if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
  62.             return;
  63.         if (!SF->getSAMP()->IsInitialized())
  64.             return;
  65.  
  66.         SF->getSAMP()->registerChatCommand("ti", cmd_ti);
  67.         SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(0, 0x77, 0xCC), "[0.3] StatisticPanel | /ti");
  68.         pFont = SF->getRender()->CreateNewFont("Tahoma", 12, FCR_BORDER);
  69.         SF->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present);
  70.  
  71.         init = true;
  72.     }
  73. }
  74.  
  75. BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
  76. {
  77.     switch (dwReasonForCall)
  78.     {
  79.         case DLL_PROCESS_ATTACH:
  80.             SF->initPlugin(mainloop, hModule);
  81.             break;
  82.         case DLL_THREAD_ATTACH:
  83.         case DLL_THREAD_DETACH:
  84.         case DLL_PROCESS_DETACH:
  85.             break;
  86.     }
  87.     return TRUE;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement