Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. // includes
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <string>
  5. #include "./headers/FLHook.h"
  6. #include "./headers/plugin.h"
  7.  
  8. PLUGIN_RETURNCODE returncode;
  9.  
  10.  
  11. EXPORT void UserCmd_Help(uint iClientID, wstring wscParam)
  12. {
  13.  
  14.     PrintUserCmdText(iClientID, L"/rules [pagenum]");
  15.    
  16. }
  17.  
  18. EXPORT PLUGIN_RETURNCODE Get_PluginReturnCode()
  19. {
  20.     return returncode;
  21. }
  22.  
  23. EXPORT void UserCmd_Rules(uint iClientID, wstring wscParam)
  24. {
  25.     PrintUserCmdText(iClientID, L"test");
  26. }
  27.  
  28. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  29.  
  30. typedef void (*_UserCmdProc)(uint, wstring);
  31.  
  32. struct USERCMD
  33. {
  34.     wchar_t *wszCmd;
  35.     _UserCmdProc proc;
  36. };
  37.  
  38. USERCMD UserCmds[] =
  39. {
  40.     { L"/rules",                    UserCmd_Rules},
  41. };
  42.  
  43. EXPORT bool UserCmd_Process(uint iClientID, wstring wscCmd)
  44. {
  45.  
  46.     wstring wscCmdLower = ToLower(wscCmd);
  47.  
  48.    
  49.     for(uint i = 0; (i < sizeof(UserCmds)/sizeof(USERCMD)); i++)
  50.     {
  51.         if(wscCmdLower.find(ToLower(UserCmds[i].wszCmd)) == 0)
  52.         {
  53.             wstring wscParam = L"";
  54.             if(wscCmd.length() > wcslen(UserCmds[i].wszCmd))
  55.             {
  56.                 if(wscCmd[wcslen(UserCmds[i].wszCmd)] != ' ')
  57.                     continue;
  58.                 wscParam = wscCmd.substr(wcslen(UserCmds[i].wszCmd) + 1);
  59.             }
  60.             UserCmds[i].proc(iClientID, wscParam);
  61.  
  62.             returncode = SKIPPLUGINS_NOFUNCTIONCALL; // we handled the command, return immediatly
  63.             return true;
  64.         }
  65.     }
  66.    
  67.     returncode = DEFAULT_RETURNCODE; // we did not handle the command, so let other plugins or FLHook kick in
  68.     return false;
  69. }
  70.  
  71. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  72.  
  73. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  74. {
  75.     return true;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement