Raised This Month: $ Target: $400
 0% 

Double SDKHook calls


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 03-31-2014 , 02:58   Double SDKHook calls
Reply With Quote #1

I've posted this on SDKHook thread but no one seems to watch it anymore. So here is my problem:

I have a "Double Hook" issue on CS:GO

When running that simple code:
PHP Code:
#include <sourcemod>
#include <sdkhooks>

public Hook_OnWeaponSpawned(weaponEntity)
{
    
PrintToChatAll("Hook_OnWeaponSpawned %d"weaponEntity);
}


public 
OnEntityCreated(entity, const String:classname[])
{
    
    if(
StrEqual(classname"weapon_knife"))
    {
        
PrintToChatAll("OnEntityCreated %d"entity);
        
SDKHook(entitySDKHook_SpawnHook_OnWeaponSpawned);
    }

OnEntityCreated gets called once but Hook_OnWeaponSpawned is called twice...

What could be causing this?

Note: My SdKtool version
Code:
[10] SDK Hooks (1.5.4-dev+4028): Source SDK Hooks
h3bus is offline
psychonic

BAFFLED
Join Date: May 2008
Old 03-31-2014 , 09:20   Re: Double SDKHook calls
Reply With Quote #2

Does this happen for other entities and hooks? Is it possible that the game is just calling Spawn twice on the knife?
psychonic is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 03-31-2014 , 09:22   Re: Double SDKHook calls
Reply With Quote #3

Some hooks are really calling twice in CS:GO, even HookEvent.
I think its only happening on certain conditions, such as warmup round or something liek that.
However, I havent had any issues with it for long time.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 03-31-2014 , 10:33   Re: Double SDKHook calls
Reply With Quote #4

I've witnessed it also with reload events. And this happens for all weapons (I did not monitor it for other entities type). I also tried with Post events, same behavior.
From my tests, it also happens outside of warmup.

This does not cause plugin failure currently but increases CPU load.

On a side note I've also noticed that behavior months ago with OnMapStart being called twice after plugin autoload, don't know if this is related.
h3bus is offline
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 03-31-2014 , 13:45   Re: Double SDKHook calls
Reply With Quote #5

After checking this does not occur for reloads.
I was hooking them twice due to the double spawn event.

I've filtered that by tagging entity when it's already hooked, but it's hacky!
h3bus is offline
Reply



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 05:21.


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