Raised This Month: $12 Target: $400
 3% 

HookEntityOutput hooks not only specified entity classname


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 05-15-2020 , 07:42   HookEntityOutput hooks not only specified entity classname
Reply With Quote #1

The code below hooks OutValue of all math_counter entities:

Code:
public void OnPluginStart()
{
	HookEntityOutput("math_counter", "OutValue", OnDamageCounter);
}

public void OnDamageCounter(const char[] output, int caller, int activator, float delay)
{
	float flMaxParam = GetEntPropFloat(caller, Prop_Data, "m_flMax");
}
It works fine, but it appears that it also hooks trigger_multiple sometimes.

Quote:
L 05/15/2020 - 01:48:11: [SM] Exception reported: Property "m_flMax" not found (entity 259/trigger_multiple)
L 05/15/2020 - 01:48:11: [SM] Blaming: showdamage.smx
L 05/15/2020 - 01:48:11: [SM] Call stack trace:
L 05/15/2020 - 01:48:11: [SM] [0] GetEntPropFloat
L 05/15/2020 - 01:48:11: [SM] [1] Line 52, showdamage.sp::OnDamageCounter
how can I prevent that without comparing the classnames?

Last edited by kadet.89; 05-15-2020 at 07:42.
kadet.89 is offline
Send a message via Skype™ to kadet.89
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-15-2020 , 08:34   Re: HookEntityOutput hooks not only specified entity classname
Reply With Quote #2

This looks fairly broken but I can't see anything obviously wrong - can you open an issue on GitHub?

As a workaround you can probably use OnEntityCreated and HookSingleEntityOutput, but I'm not sure if that'll be any more efficient than just checking the classname in the callback.
__________________
asherkin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-15-2020 , 09:24   Re: HookEntityOutput hooks not only specified entity classname
Reply With Quote #3

To check, does entity have property.
HasEntProp
https://sm.alliedmods.net/new-api/entity/HasEntProp


...Work as long as other entity class not have same property.
In this case, math_counter only own "m_flMax".
Code:
CBaseEntity - math_counter
- m_bHitMax (Offset 921) (Save)(1 Bytes)
- m_bHitMin (Offset 920) (Save)(1 Bytes)
- m_flMin (Offset 912) (Save|Key)(4 Bytes) - min
- m_flMax (Offset 916) (Save|Key)(4 Bytes) - max

Just compare entity classname.


*edit
Maybe, in that trigger or math_counter, it pass another entity (!self, !player, !caller, !activator) ??

Last edited by Bacardi; 05-15-2020 at 09:33.
Bacardi is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 05-15-2020 , 15:55   Re: HookEntityOutput hooks not only specified entity classname
Reply With Quote #4

Quote:
Originally Posted by asherkin View Post
can you open an issue on GitHub?
I'll try to find time.

I checked logs and found that it happens with other entities on different maps
zm_stab_heat -> func_breakable
ze_icecap_escape_v5_p -> func_breakable
ze_resonance_cascade_p3 -> trigger_once
ze_Pidaras_va2
Exception reported: Property "m_flMax" not found (entity -606988873/filter_multi)
Exception reported: Property "m_flMax" not found (entity 131/trigger_once)
ze_chicken_ranch_v2_2 -> func_breakable

Most of the maps don't have any math_counter
kadet.89 is offline
Send a message via Skype™ to kadet.89
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-17-2020 , 07:00   Re: HookEntityOutput hooks not only specified entity classname
Reply With Quote #5

Someone on IRC pointed out that this is actually fixed in 1.11 - it’s an old bug and quite a major change so the fix isn’t backported.
__________________
asherkin 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 07:21.


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