Using SourceHook
Ive seen some sourcecode I believe it was for sdktools...used for hooking into IVoiceServer.
Ive tried taking the source and hooking into the IVoiceServer myself In my plugin...but I cant get it to work. As soon as I try to do the hook..it crashs I call SH_ADD_HOOK_MEMFUNC(IVoiceServer, SetClientListening, g_pVoiceServer, &g_EmtpyServerPlugin,&CEmptyServerPlugin::OnS etClientListening, false); but am having trouble. Can anyone help me out to be able to hook into the setclientlistening functions so I can set up a proper mute function? |
Re: Using SourceHook
That line looks fine..
Probably need to see the full code to try spot the problem. |
Re: Using SourceHook
I scrapped out the code from sdktools source that I have from somewhere.
I changed it a bit because I dont have a IPluginContext pointer (passing null to test but each use of it is checked). PHP Code:
|
Re: Using SourceHook
Params arrays have the first index (0) as the number of params.
Notice you set t[0] = 4; then int index=params[1]; t[1] is uninitialised.. You don't need the sp_nativeinfo_t since thats just to register the commands as natives. |
Re: Using SourceHook
i actually have it
t[0]=4; t[1]=4; I call the function and step thru it until it does the sh_add_hook_memfunc and it then crashs at the SH_DECL_HOOK3(IVoiceServer, SetClientListening, SH_NOATTRIB, 0, bool, int, int, bool); line of code |
Re: Using SourceHook
Thought that sounded too easy.
One of the pointers you are passing maybe? g_pVoiceServer? |
Re: Using SourceHook
i verified its not null ...
and its appears good in :Load |
Re: Using SourceHook
When I Call the SH_ADD_HOOK_MEMFUNC(IVoiceServer, SetClientListening, g_pVoiceServer,&g_EmtpyServerPlugin,&CEmptySe rverPlugin::OnSetClientListening, false);
g_pVoiceServer is valid, g_EmptyServerPlugin is My main plugin class and is valid as well.. I still dont see why it crashs... with a breakpoint on SH_DECL_HOOK3 it appears to be hooking in ...i see it going thru the macro's etc for fastdelegate etc.. but 3rd time it goes thru sh_decl_hook3 it crashs does the class that I pass in for handler_inst have to be derived from a specific class or something? |
Re: Using SourceHook
The problem is with my not initializing source hook variable
SourceHook::ISourceHook *g_SHPtr How do I initialize sourcehook correctly. Im trying to follow the wiki at http://wiki.alliedmods.net/SourceHoo...t#Simple_Hooks but Im not having much luck. |
Re: Using SourceHook
Is this a metamod plugin or a VSP?
The embedding section on that wiki page suggests that multiple versions of sourcehook in the same process will probably conflict, so not entirely sure how you'd add it to a VSP if metamod is running. If it's metamod you need something like this in your metamod load function: g_SHPtr = static_cast<SourceHook::ISourceHook *>(ismm->MetaFactory(MMIFACE_SOURCEHOOK, NULL, NULL)); g_PLID = id; or look at the PLUGIN_SAVEVARS() macro in ISmmPlugin.h |
All times are GMT -4. The time now is 21:03. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.