AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Question about RegisterHam (wildcard) (https://forums.alliedmods.net/showthread.php?t=281594)

gabuch2 04-15-2016 10:03

Question about RegisterHam (wildcard)
 
RegisterHam requires an EntityClass in order to register the hook.
Can I use a wildcard in this EntityClass? For example: RegisterHam on trigger_* will work on all trigger_ entities.
Or I need to create a RegisterHam for each one?

Thanks in advance.

SpeeDeeR 04-15-2016 10:18

Re: Question about RegisterHam (wildcard)
 
You cant use trigger_*

siriusmd99 04-15-2016 11:00

Re: Question about RegisterHam (wildcard)
 
You can try , If the callback is compared with something like contain function then it would be possible but if is compared by equal function then you'll have to write exact name.

try to put "trigger_"

klippy 04-15-2016 12:02

Re: Question about RegisterHam (wildcard)
 
Hamsandwich doesn't really work by entity class, but rather C++ class that entity is linked to.

As an example, if you hooked spawn on "info_target", you would also hook it for "info_player_start" and "info_player_deathmatch" (and possibly few more) as they are all linked to the CPointEntity class.

https://mxr.alliedmods.net/hlsdk/sou...ls/cbase.h#388
https://mxr.alliedmods.net/hlsdk/sou...effects.cpp#32
https://mxr.alliedmods.net/hlsdk/sou...ls/subs.cpp#70

That also explains some confusion I've seen around this forums, there were a few topics asking about why some other entity's virtual functions were hooked when they didn't tell Hamsandwich to hook them.

Well, you can't use wildcards because of what I've said above. Hamsandwich doesn't make classname checks at run-time each time some virtual function is called, it just changes some function pointers around in virtual tables, and each C++ class has its own. :)

gabuch2 04-15-2016 13:24

Re: Question about RegisterHam (wildcard)
 
From what I can understand, if I hook monster_generic, for example, all entities linked to CBaseMonster will be hooked?

klippy 04-15-2016 13:31

Re: Question about RegisterHam (wildcard)
 
Correct, altough monster_generic is linked to CGenericMonster. Here, take a look yourself.

All you would have to do in your hooks to get around that is to check for the classname yourself.


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

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