AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Hook CBaseEntity::FireBullets (https://forums.alliedmods.net/showthread.php?t=166630)

M1NDFREAK 09-05-2011 16:16

Hook CBaseEntity::FireBullets
 
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?

asherkin 09-06-2011 19:43

Re: Hook CBaseEntity::FireBullets
 
You aren't using SourceHook.

M1NDFREAK 09-07-2011 08:58

Re: Hook CBaseEntity::FireBullets
 
Yes because I'm writing a VSP and I can only use SourceHook in a MetaMod-Plugin right?

psychonic 09-07-2011 09:05

Re: Hook CBaseEntity::FireBullets
 
Quote:

Originally Posted by M1NDFREAK (Post 1549956)
Yes because I'm writing a VSP

Quote:

AlliedModders Forum Index > SourceMod > Metamod: Source > Coding MM:S Plugins for HL2

Afronanny 09-07-2011 11:07

Re: Hook CBaseEntity::FireBullets
 
Quote:

Originally Posted by M1NDFREAK (Post 1549956)
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.

Chrisber 09-09-2011 10:10

Re: Hook CBaseEntity::FireBullets
 
So, aren't detouring and hooking basicly the same idea?

Wazz 09-09-2011 17:54

Re: Hook CBaseEntity::FireBullets
 
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.

pRED* 09-10-2011 20:11

Re: Hook CBaseEntity::FireBullets
 
Quote:

Originally Posted by Wazz (Post 1551734)
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.

asherkin 09-10-2011 20:12

Re: Hook CBaseEntity::FireBullets
 
Quote:

Originally Posted by pRED* (Post 1552662)
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.

Afronanny 09-11-2011 10:26

Re: Hook CBaseEntity::FireBullets
 
VSPs are devilishly useful for things you want to keep running even when MM:S breaks. Because VSPs almost never break.


All times are GMT -4. The time now is 08:54.

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