AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Using SourceHook (https://forums.alliedmods.net/showthread.php?t=78669)

BeetleFart 11-06-2008 14:07

Re: Using SourceHook
 
Im now trying to hook
the WeaponCanUse virtual function

SH_DECL_MANUALHOOK1(WeaponCanUseHook, 0, 0, 0, bool, CBaseCombatWeapon *);
declared globally

i added into clientactive:

int Offset=216;
SH_MANUALHOOK_RECONFIGURE(WeaponCanUseHook, Offset, 0, 0);
SH_ADD_MANUALHOOK_MEMFUNC(WeaponCanUseHook, pBase, &g_EmtpyServerPlugin, &CEmptyServerPlugin::WeaponCanUseFunction, false);

and have:
bool CEmptyServerPlugin::WeaponCanUseFunction(CBas eCombatWeapon *pWeapon)
{
RETURN_META_VALUE(MRES_IGNORED, false);
}

and it appears to hook etc...but when the WeaponCanUseFunction is called
it comes up with and ESP problem with parameters not being stored correctly across the function call and Dont know what Im doing wrong.
I want to hook if someone can use a specific weapon .
What am I doing incorrectly?

BeetleFart 11-06-2008 15:23

Re: Using SourceHook
 
Im not sure what I did..but I redid it and now it seems to be working correctly.
Not sure what was wrong..maybe I had the offset wrong or something

L. Duke 11-07-2008 11:13

Re: Using SourceHook
 
Yes, I've had that error when I have the wrong offset or if the function parameters or call type are defined wrong.

BeetleFart 01-07-2009 11:52

Re: Using SourceHook
 
Does anyone know if theres something I need to do with sourcehook and linux.
Ive added a soucehook into the g_VoiceServer to trap the voice comms
and it works great in windows. I have one linux box that its being tested on
and when I do the sh_add_hook_memfunc it returns a 1 (or number of times Ive hooked it)
but the OnSetClientListening function never gets called on the linux box.
I would think that if the return value was ok..like it appears to be ..that the
hook is in place..or is the return value of 1 when I hook it once incorrect?

BeetleFart 01-08-2009 12:40

Re: Using SourceHook
 
anyone know why a hook would work in windows but not in linux???


All times are GMT -4. The time now is 18:40.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.