Raised This Month: $32 Target: $400
 8% 

Hook CBaseEntity::FireBullets


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
M1NDFREAK
Junior Member
Join Date: Nov 2010
Old 09-05-2011 , 16:16   Hook CBaseEntity::FireBullets
Reply With Quote #1

Hello,
i try to hook FireBullets but it doesn't work.
I Hook it like this: (windows)

PHP Code:
#define HVFUNC( funcname, returntype, proto) \
    
typedef returntype __stdcall funcname##Func ) proto ; \
    
extern funcname##Func funcname; \
    
extern CVirtualCallGate funcname##Gate; \
    
returntype __stdcall funcname##_hook proto;

#define HOOKVFUNC( classptr , index , funcname ) \
    
if (! funcname##Gate.IsBuilt() ) { \
    
DeProtect((void*)VTBLclassptr ), ( index sizeof(void*)) + ); \
    
funcname##Gate.Build((void*)VFN( classptr , index ), funcname##_hook , & funcname ); \
    
*(DWORD*)PVFNclassptr index ) = funcname##Gate.Gate(); \
    
}

HVFUNC(h_FireBulletsvoid, ( CBasePlayerpPlayer, const FireBulletsInfo_t &info ))


DEFVFUNC(h_FireBulletsvoid, ( CBasePlayerpPlayer, const FireBulletsInfo_t &info ))
{
    
Msg("h_FireBullets called @ %.1f\n"gpGlobals->curtime);
    
h_FireBullets(pPlayer,info);
}

void TestPlugin::ClientActiveedict_t *pEntity )
{
    
CBaseEntity *pBaseEnt pEntity->GetUnknown()->GetBaseEntity();
    
HOOKVFUNC(pBaseEnt110h_FireBullets);

What am I doing wrong?
M1NDFREAK is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-06-2011 , 19:43   Re: Hook CBaseEntity::FireBullets
Reply With Quote #2

You aren't using SourceHook.
__________________
asherkin is offline
M1NDFREAK
Junior Member
Join Date: Nov 2010
Old 09-07-2011 , 08:58   Re: Hook CBaseEntity::FireBullets
Reply With Quote #3

Yes because I'm writing a VSP and I can only use SourceHook in a MetaMod-Plugin right?
M1NDFREAK is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-07-2011 , 09:05   Re: Hook CBaseEntity::FireBullets
Reply With Quote #4

Quote:
Originally Posted by M1NDFREAK View Post
Yes because I'm writing a VSP
Quote:
AlliedModders Forum Index > SourceMod > Metamod: Source > Coding MM:S Plugins for HL2
psychonic is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 09-07-2011 , 11:07   Re: Hook CBaseEntity::FireBullets
Reply With Quote #5

Quote:
Originally Posted by M1NDFREAK View Post
Yes because I'm writing a VSP and I can only use SourceHook in a MetaMod-Plugin right?
You can embed SourceHook in a VSP.

Anyhow, why mess about with hooking when you can detour? Detouring is easier to manage.
Afronanny is offline
Chrisber
AlliedModders Donor
Join Date: Jul 2007
Location: localhost
Old 09-09-2011 , 10:10   Re: Hook CBaseEntity::FireBullets
Reply With Quote #6

So, aren't detouring and hooking basicly the same idea?
Chrisber is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 09-09-2011 , 17:54   Re: Hook CBaseEntity::FireBullets
Reply With Quote #7

Don't listen to Afronappy, SourceHook manages the hooks which makes it 100 times better and improves your plugin's compatibility with other plugins. Use it.
Wazz is offline
pRED*
Join Date: Dec 2006
Old 09-10-2011 , 20:11   Re: Hook CBaseEntity::FireBullets
Reply With Quote #8

Quote:
Originally Posted by Wazz View Post
Don't listen to Afronappy, SourceHook manages the hooks which makes it 100 times better and improves your plugin's compatibility with other plugins. Use it.
SourceHook can only improve compatibility with other plugins when both plugins are sharing the same instance of it. This is true for MM:S plugins, but if you embed your own copy of SH, then you will (potentially) run into the exact same resource conflicts as you would with detouring/other hooking methods.
pRED* is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-10-2011 , 20:12   Re: Hook CBaseEntity::FireBullets
Reply With Quote #9

Quote:
Originally Posted by pRED* View Post
SourceHook can only improve compatibility with other plugins when both plugins are sharing the same instance of it. This is true for MM:S plugins, but if you embed your own copy of SH, then you will (potentially) run into the exact same resource conflicts as you would with detouring/other hooking methods.
Which is why MM:S exists and why no one should be making VSPs.
__________________
asherkin is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 09-11-2011 , 10:26   Re: Hook CBaseEntity::FireBullets
Reply With Quote #10

VSPs are devilishly useful for things you want to keep running even when MM:S breaks. Because VSPs almost never break.
Afronanny is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:21.


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