Guest User

Saul Rennison

a guest
Jan 4th, 2010
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. //-----------------------------------------------------------------------------
  2. // SourceHook
  3. //-----------------------------------------------------------------------------
  4. using namespace SourceHook;
  5.  
  6. Impl::CSourceHookImpl g_SourceHook;
  7. ISourceHook *g_SHPtr = &g_SourceHook;
  8. int g_PLID = 0;
  9.  
  10. SH_DECL_HOOK1_void(IBaseClientDLL, FrameStageNotify, SH_NOATTRIB, 0, ClientFrameStage_t);
  11.  
  12. //-----------------------------------------------------------------------------
  13. //
  14. //-----------------------------------------------------------------------------
  15. bool CServerPlugin::Load( CreateInterfaceFn pfnEngineFactory, CreateInterfaceFn pfnGameFactory )
  16. {
  17.     ...
  18.  
  19.     CSysModule *pClientModule = g_pFullFileSystem->LoadModule("bin/client.dll", "MOD", false);
  20.     if(!pClientModule)
  21.     {
  22.         Warning("Unable to find client DLL module (are you on a dedicated server?)\n");
  23.         return false;
  24.     }
  25.  
  26.     CreateInterfaceFn pfnClientFactory = Sys_GetFactory(pClientModule);
  27.     if(!pfnClientFactory)
  28.     {
  29.         Warning("Unable to retrieve client factory\n");
  30.         return false;
  31.     }
  32.  
  33.     g_pClient = UTIL_LoadInterface<IBaseClientDLL>(pfnClientFactory, CLIENT_DLL_INTERFACE_VERSION, bSuccess);
  34.  
  35.     // Initialize hooks
  36.     SH_ADD_HOOK(IBaseClientDLL, FrameStageNotify, g_pClient, SH_MEMBER(&s_ClientPlugin, &CClientPlugin::FrameStageNotify), true);
  37. }
  38.  
  39. //-----------------------------------------------------------------------------
  40. //
  41. //-----------------------------------------------------------------------------
  42. void CServerPlugin::Unload( void )
  43. {
  44.     ...
  45.  
  46.     // Remove hooks
  47.     SH_REMOVE_HOOK(IBaseClientDLL, FrameStageNotify, g_pClient, SH_MEMBER(&s_ClientPlugin, &CClientPlugin::FrameStageNotify), true);
  48. }
  49.  
  50. //-----------------------------------------------------------------------------
  51. //
  52. //-----------------------------------------------------------------------------
  53. void CClientPlugin::FrameStageNotify( ClientFrameStage_t curStage )
  54. {
  55.     // Do your code here
  56. }
Advertisement
Add Comment
Please, Sign In to add comment