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

DHooks (Dynamic Hooks - Dev Preview)


Post New Thread Reply   
 
Thread Tools Display Modes
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 08-04-2016 , 16:35   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #471

can you post the rest of the code and the error log. It doesnt look possible for an invalid handle to be passed. It checks if the handle was created before calling the callback.
Dr!fter is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 08-04-2016 , 16:59   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #472

Creating a DHook:
Code:
    new offset = GameConfGetOffset(gameDataFile, "SetObserverTarget");
    h_SetObserverTarget = DHookCreate(offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, OnClientObserve);
    DHookAddParam(h_SetObserverTarget, HookParamType_CBaseEntity);
The DHook:
Code:
public MRESReturn:OnClientObserve (client, Handle:hReturn, Handle:hParams)
{
    // As of DHooks 1.0.12 we must check for a null param.
    if (g_bCheckNullPtr && DHookIsNullParam(hParams, 1)) // ERROR LINE. This was commented out for the error output.
        return MRES_Ignored;

    static target;
    target = DHookGetParam(hParams, 1); // ERROR LINE
}
THE ERROR:
Code:
L 08/04/2016 - 15:33:25: [SM] Exception reported: Invalid Handle 1 (error 1)
L 08/04/2016 - 15:33:25: [SM] Blaming: dhook_observer.smx()
L 08/04/2016 - 15:33:25: [SM] Call stack trace:
L 08/04/2016 - 15:33:25: [SM]   [0] DHookGetParam
L 08/04/2016 - 15:33:25: [SM]   [1] Line 65, C:\Users\Dils\OneDrive\Development\giclan\sourcemod_18\scripting\dhook_observer.sp::OnClientObserve()
L 08/04/2016 - 15:33:25: [SM]   [3] Call_Finish
L 08/04/2016 - 15:33:25: [SM]   [4] Line 72, C:\Users\Dils\OneDrive\Development\giclan\sourcemod_18\scripting\dhook_observer.sp::OnClientObserve()

Last edited by dilalmon; 08-04-2016 at 17:01. Reason: SetObserverTarget: 420 for windows, 421 for Linux
dilalmon is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 08-04-2016 , 18:43   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #473

Can you pm me the entire plugin.
Dr!fter is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 08-04-2016 , 18:51   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #474

What I posted is pretty much the whole plugin, but I sent it!
dilalmon is offline
dilalmon
AlliedModders Donor
Join Date: Apr 2013
Old 08-04-2016 , 19:15   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #475

I take this back...
The forward had the same name, "OnClientObserve()".

....

I'm so sorry for bothering you.
I really appreciate your help, though.

dilalmon is offline
klausenbusk
AlliedModders Donor
Join Date: Jan 2011
Old 08-05-2016 , 11:08   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #476

I'm trying to hook CanHavePlayerItem in CS:S, so CT can pick up C4.
Either I'm doing something wrong or then it isn't fired.
My code:
Code:
#include <sourcemod>
#include <dhooks>
#pragma semicolon 1

new Handle:g_hSetObserverMode; 

public Plugin:myinfo =
{
    name = "C4",
    author = "KK",
    description = "",
    version = "1.0.0",
    url = "http://steamcommunity.com/id/i_like_denmark/"
};

public OnPluginStart() 
{
    new Handle:temp = LoadGameConfigFile("c4-offsets.games");
    if(temp == INVALID_HANDLE)
    {    
        SetFailState("Why you no has gamedata?");
    }

    new offset = GameConfGetOffset(temp, "CanHavePlayerItem");
    g_hSetObserverMode = DHookCreate(offset, HookType_GameRules, ReturnType_Bool, ThisPointer_CBaseEntity, CanHavePlayerItem);
    DHookAddParam(g_hSetObserverMode, HookParamType_CBaseEntity);
    DHookAddParam(g_hSetObserverMode, HookParamType_CBaseEntity);
    
    CloseHandle(temp);
}

public MRESReturn:CanHavePlayerItem(this, Handle:hReturn, Handle:hParams)
{
    PrintToChatAll("hi");
}
Offsets (found with https://asherkin.github.io/vtable/)
Code:
"Games"
{
        "cstrike"
        {
                "Offsets"
                {
                        "CanHavePlayerItem"
                        {
                                "windows"       "86"
                                "linux"         "87"
                        }
                }
        }
}
Edit: stupid me, I totally forgot hooking it..

Edit2: So BumpWeapon is fired for C4, but CanHavePlayerItem isn't. So some check done in BumpWeapon is false before it get to CanHavePlayerItem.
CanHavePlayerItem is fired for all other weapons, also EquipWeapon doesn't work it just remove the weapon from the world.

Last edited by klausenbusk; 08-05-2016 at 12:31.
klausenbusk is offline
jking
AlliedModders Donor
Join Date: Jan 2012
Old 08-05-2016 , 16:00   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #477

Guys, please excuse my ignorance but several of my plugins on my L4D2 DS use this but if I may, I've installed this as usual, v 2.0.6-hg101 and on the latest SM 1.8.0-git5925-windows, compiled .smx to the plugins afterward and upon startup I receive this error:

Code:
L 08/05/2016 - 13:58:48: SourceMod error session started
L 08/05/2016 - 13:58:48: Info (map "c5m1_waterfront") (file "errors_20160805.log")
L 08/05/2016 - 13:58:48: [SM] Exception reported: Failed to get CreateInterface
L 08/05/2016 - 13:58:48: [SM] Blaming: dhooks-test.smx()
L 08/05/2016 - 13:58:48: [SM] Call stack trace:
L 08/05/2016 - 13:58:48: [SM]   [0] SetFailState
L 08/05/2016 - 13:58:48: [SM]   [1] Line 99, dhooks-test.sp::OnPluginStart()
L 08/05/2016 - 13:58:48: [SM] Unable to load plugin "dhooks-test.smx": Error detected in plugin startup (see error logs)
L 08/05/2016 - 13:58:54: Error log file session closed.

Last edited by jking; 08-05-2016 at 16:02.
jking is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-05-2016 , 21:19   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #478

The test plugin probably doesn't have gamedata for L4D2. Remove the test plugin and see if it works.
Potato Uno is offline
jking
AlliedModders Donor
Join Date: Jan 2012
Old 08-05-2016 , 21:25   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #479

Quote:
Originally Posted by Potato Uno View Post
The test plugin probably doesn't have gamedata for L4D2. Remove the test plugin and see if it works.
Hi Potato, yes taking it out seems to not break anything that I've seen, thanks for your reply.
jking is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 08-09-2016 , 12:23   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #480

Quote:
Originally Posted by klausenbusk View Post
I'm trying to hook CanHavePlayerItem in CS:S, so CT can pick up C4.
Either I'm doing something wrong or then it isn't fired.
My code:
Code:
#include <sourcemod>
#include <dhooks>
#pragma semicolon 1

new Handle:g_hSetObserverMode; 

public Plugin:myinfo =
{
    name = "C4",
    author = "KK",
    description = "",
    version = "1.0.0",
    url = "http://steamcommunity.com/id/i_like_denmark/"
};

public OnPluginStart() 
{
    new Handle:temp = LoadGameConfigFile("c4-offsets.games");
    if(temp == INVALID_HANDLE)
    {    
        SetFailState("Why you no has gamedata?");
    }

    new offset = GameConfGetOffset(temp, "CanHavePlayerItem");
    g_hSetObserverMode = DHookCreate(offset, HookType_GameRules, ReturnType_Bool, ThisPointer_CBaseEntity, CanHavePlayerItem);
    DHookAddParam(g_hSetObserverMode, HookParamType_CBaseEntity);
    DHookAddParam(g_hSetObserverMode, HookParamType_CBaseEntity);
    
    CloseHandle(temp);
}

public MRESReturn:CanHavePlayerItem(this, Handle:hReturn, Handle:hParams)
{
    PrintToChatAll("hi");
}
Offsets (found with https://asherkin.github.io/vtable/)
Code:
"Games"
{
        "cstrike"
        {
                "Offsets"
                {
                        "CanHavePlayerItem"
                        {
                                "windows"       "86"
                                "linux"         "87"
                        }
                }
        }
}
Edit: stupid me, I totally forgot hooking it..

Edit2: So BumpWeapon is fired for C4, but CanHavePlayerItem isn't. So some check done in BumpWeapon is false before it get to CanHavePlayerItem.
CanHavePlayerItem is fired for all other weapons, also EquipWeapon doesn't work it just remove the weapon from the world.
I believe what you want is Weapon_CanUse.

Also updated, fixed a small bug with vector returns.
Dr!fter 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 11:48.


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