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

SDK Hooks 2.1 - Updated 2011-9-10


Post New Thread Closed Thread   
 
Thread Tools Display Modes
TavidBlower
Junior Member
Join Date: Apr 2012
Old 04-28-2012 , 14:23   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1821

L 04/28/2012 - 19:57:42: SourceMod error session started
L 04/28/2012 - 19:57:42: Info (map "de_dust2") (file "errors_20120428.log")
L 04/28/2012 - 19:57:42: [SM] Unable to load extension "sdkhooks.ext": /games/ni70903_2/ftproot/srcds_l/css/cstrike/addons/sourcemod/extensions/sdkhooks.ext.so: cannot open shared object file: No such file or directory
L 04/28/2012 - 19:57:43: [SM] Unable to load plugin "zombiereloaded.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 04/28/2012 - 20:04:07: SourceMod error session started
L 04/28/2012 - 20:04:07: Info (map "de_dust2") (file "errors_20120428.log")
L 04/28/2012 - 20:04:07: [SM] Unable to load extension "sdkhooks.ext": /games/ni70903_2/ftproot/srcds_l/css/cstrike/addons/sourcemod/extensions/sdkhooks.ext.so: cannot open shared object file: No such file or directory
L 04/28/2012 - 20:04:07: [SM] Unable to load plugin "zombiereloaded.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 04/28/2012 - 20:041: Error log file session closed.
L 04/28/2012 - 20:041: SourceMod error session started
L 04/28/2012 - 20:041: Info (map "ze_minecraft_v1_1") (file "errors_20120428.log")
L 04/28/2012 - 20:041: [SM] Unable to load plugin "zombiereloaded.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running

i get this error if i start my server and check the errorlogs at sourcemod directory

want to start zombiemod

Metamod
1.8.7 1.8.7 Sourcemod
1.4.2 1.4.2
these are my versions of Meta & Source

why it failed?

*ZombieMod Reloaded 3.0.0 Beta 2
*ZombieMod Reloaded 3.0 b2 Patch

i use this

Last edited by TavidBlower; 04-28-2012 at 14:33.
TavidBlower is offline
TavidBlower
Junior Member
Join Date: Apr 2012
Old 04-28-2012 , 14:58   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1822

it WORKS!!!!!!!
i have download the wrong hooks -.-
my server is linux and i have use windows xD
im a idiot!
TavidBlower is offline
Ambit
Junior Member
Join Date: May 2012
Old 05-16-2012 , 23:24   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1823

OnTakeDamagePost is crashing the server when I use it.

The values in OnTakeDamagePost are all wrong and Visual Studio says the server crash is due to an access violation.

This is the relevant code:

Code:
public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage)
    SDKHook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePost)
}


public Action:OnTakeDamagePost(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    LogMessage("OnTakeDamagePost start")
    //LogMessage("Victim: %d", victim)
    LogMessage("Attacker: %d", attacker)
    LogMessage("Damage: %f", damage)
}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{		
    LogMessage("OnTakeDamage start")
    LogMessage("Victim: %d", victim)
    LogMessage("Attacker: %d", attacker)
    LogMessage("Damage: %f", damage)

    if (victim > 1)
    {
        damage = 0.0
        return Plugin_Changed
    }
    return Plugin_Continue
}
And the log output:

Code:
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamage start
L 05/16/2012 - 19:47:10: [freezetag.smx] Victim: 4
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 3
L 05/16/2012 - 19:47:10: [freezetag.smx] Damage: 12.000000
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamagePost start
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 12846
L 05/16/2012 - 19:47:10: [freezetag.smx] Damage: 0.000000
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamage start
L 05/16/2012 - 19:47:10: [freezetag.smx] Victim: 1
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 5
L 05/16/2012 - 19:47:10: [freezetag.smx] Damage: 30.000000
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamagePost start
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 805306368
The server had friendly fire on and all of the other players were bots on the opposite team from me. Trying to access the victim id from OnTakeDamage post always resulted in a crash, so I had to comment it out. I'm not sure why reading damage worked the first time but crashed the second, but you can clearly see that the attacker id in OnTakeDamagePost is garbage.
Ambit is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-16-2012 , 23:49   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1824

Quote:
Originally Posted by Ambit View Post
OnTakeDamagePost is crashing the server when I use it.

The values in OnTakeDamagePost are all wrong and Visual Studio says the server crash is due to an access violation.

This is the relevant code:

Code:
public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage)
    SDKHook(client, SDKHook_OnTakeDamagePost, OnTakeDamagePost)
}


public Action:OnTakeDamagePost(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    LogMessage("OnTakeDamagePost start")
    //LogMessage("Victim: %d", victim)
    LogMessage("Attacker: %d", attacker)
    LogMessage("Damage: %f", damage)
}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{		
    LogMessage("OnTakeDamage start")
    LogMessage("Victim: %d", victim)
    LogMessage("Attacker: %d", attacker)
    LogMessage("Damage: %f", damage)

    if (victim > 1)
    {
        damage = 0.0
        return Plugin_Changed
    }
    return Plugin_Continue
}
And the log output:

Code:
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamage start
L 05/16/2012 - 19:47:10: [freezetag.smx] Victim: 4
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 3
L 05/16/2012 - 19:47:10: [freezetag.smx] Damage: 12.000000
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamagePost start
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 12846
L 05/16/2012 - 19:47:10: [freezetag.smx] Damage: 0.000000
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamage start
L 05/16/2012 - 19:47:10: [freezetag.smx] Victim: 1
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 5
L 05/16/2012 - 19:47:10: [freezetag.smx] Damage: 30.000000
L 05/16/2012 - 19:47:10: [freezetag.smx] OnTakeDamagePost start
L 05/16/2012 - 19:47:10: [freezetag.smx] Attacker: 805306368
The server had friendly fire on and all of the other players were bots on the opposite team from me. Trying to access the victim id from OnTakeDamage post always resulted in a crash, so I had to comment it out. I'm not sure why reading damage worked the first time but crashed the second, but you can clearly see that the attacker id in OnTakeDamagePost is garbage.
According to sdkhooks.inc, you have the wrong signature for OnTakeDamagePost:

PHP Code:
    // OnTakeDamagePost
    
public(victimattackerinflictorFloat:damagedamagetype), 
Note the lack of Action return code and lack of ampersands (to indicate references). Strangely, victim is the only one that appears to have the correct argument, yet it's the one that's erroring...
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-16-2012 at 23:51.
Powerlord is offline
Ambit
Junior Member
Join Date: May 2012
Old 05-16-2012 , 23:58   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1825

That's strange. I figured at first that my issue was that I had the parameters marked to be passed by reference (it wouldn't make sense since altering the values wouldn't do anything after the function has already run), but when I removed them I got a compiler error saying that the function signature didn't match. I assumed that I must have had it correct since as it is right now I don't get a compiler error.

I also saw

Code:
int Hook_OnTakeDamage(CTakeDamageInfoHack &info);
int Hook_OnTakeDamagePost(CTakeDamageInfoHack &info);
in the source code and figured that meant that they must take the same parameters and have the same return type.

Last edited by Ambit; 05-17-2012 at 00:04.
Ambit is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-17-2012 , 10:58   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1826

Quote:
Originally Posted by Ambit View Post
That's strange. I figured at first that my issue was that I had the parameters marked to be passed by reference (it wouldn't make sense since altering the values wouldn't do anything after the function has already run), but when I removed them I got a compiler error saying that the function signature didn't match. I assumed that I must have had it correct since as it is right now I don't get a compiler error.
The reason just removing the &s didn't work is because the correct function also changes the return type (from Action tag to no tag).

The problem is that the signatures for all the callback functions are in one gigantic funcenum (a set of callback functions with the same name) named SDKHookCB, and the compiler doesn't know which the extension expects you to use for which hook type.

For reference, here's the entire set of callback declarations, taken from the 2.1 sdkhooks.inc. The comments above each type are the hook types it applies to:
PHP Code:
funcenum SDKHookCB
{
    
// PreThink/Post
    // PostThink/Post
    
public(client),
    
    
// Spawn
    
Action:public(entity),
    
    
// GroundEntChanged
    // SpawnPost
    // Think/Post
    // VPhysicsUpdate/Post
    
public(entity),
    
    
// EndTouch
    // StartTouch
    // Touch
    
Action:public(entityother),
    
    
// EndTouchPost
    // StartTouchPost
    // TouchPost
    
public(entityother),
    
    
// SetTransmit
    
Action:public(entityclient),
    
    
// WeaponCanSwitchTo
    // WeaponCanUse
    // WeaponDrop
    // WeaponEquip
    // WeaponSwitch
    
Action:public(clientweapon),
    
    
// WeaponCanSwitchToPost
    // WeaponCanUsePost
    // WeaponDropPost
    // WeaponEquipPost
    // WeaponSwitchPost
    
public(clientweapon),
    
    
// OnTakeDamage
    // Note: Force application is dependent on game and damage type(s)
    // SDKHooks 1.0+
    
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype),
    
// SDKHooks 2.0+
    
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3]),
    
// SDKHooks 2.1+  (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability.
    // DON'T attempt to access 'damagecustom' var if feature status != available
    
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon,
        
Float:damageForce[3], Float:damagePosition[3], damagecustom),
    
    
// OnTakeDamagePost
    
public(victimattackerinflictorFloat:damagedamagetype),
    public(
victimattackerinflictorFloat:damagedamagetypeweapon, const Float:damageForce[3], const Float:damagePosition[3]),
    
    
// FireBulletsPost
    
public(clientshots, const String:weaponname[]),
    
    
// TraceAttack
    
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxhitgroup),
    
    
// TraceAttackPost
    
public(victimattackerinflictorFloat:damagedamagetypeammotypehitboxhitgroup),
    
    
// ShouldCollide
    
bool:public(entitycollisiongroupcontentsmaskbool:originalResult),
    
    
// Use
    
Action:public(entityactivatorcallerUseType:typeFloat:value),
    
    
// UsePost
    
public(entityactivatorcallerUseType:typeFloat:value),
    
    
// Reload
    
Action:public(weapon),
    
    
// Reload post
    
public(weaponbool:bSuccessful)
}; 
The only way to fix this would be to make a separate hook function and callback function for each callback type, which would break backward compatibility... and make things harder to read in general.

Quote:
Originally Posted by Ambit View Post
I also saw

Code:
int Hook_OnTakeDamage(CTakeDamageInfoHack &info);
int Hook_OnTakeDamagePost(CTakeDamageInfoHack &info);
in the source code and figured that meant that they must take the same parameters and have the same return type.
Crossing the border between the C++ and SourcePawn sides is tricky. The return value is always a cell_t when crossing, and cell_t is an int on the C++ side. However, in the actual native itself, you pass things back via references using functions in the global smutils (iirc) object, and as such, values declared as references are treated differently.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-17-2012 at 11:05. Reason: Spoiler block is unnecessary, as the php block folds it up
Powerlord is offline
Marcos
Junior Member
Join Date: Jun 2008
Old 05-23-2012 , 03:48   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1827

Quote:
new weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
SDKHookEx(weapon, SDKHook_Reload, HookOnReload)
Dose anyone wonder this hook is more like SDKHook_WeaponSwitch,it's not really hook when u reload your weapon?
Marcos is offline
1deag
Junior Member
Join Date: Apr 2012
Old 05-24-2012 , 14:21   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1828

Every time I install SDK Hooks on my new server, it won't load correctly.

Code:
] sm_rcon sm plugins refresh
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "smac_wallhack.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "smac_css_antismoke.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "smac_css_antiflash.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "redie.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
[SM] The plugin list has been refreshed and reloaded.
I correctly installed it, I have done it before and it worked. Any ideas?
1deag is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-24-2012 , 15:04   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1829

Quote:
Originally Posted by 1deag View Post
Every time I install SDK Hooks on my new server, it won't load correctly.

Code:
] sm_rcon sm plugins refresh
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "smac_wallhack.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "smac_css_antismoke.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "smac_css_antiflash.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
L 05/24/2012 - 14:19:19: [SM] Unable to load plugin "redie.smx": Required extension "sdkhooks" file("sdkhooks.ext") not running
[SM] The plugin list has been refreshed and reloaded.
I correctly installed it, I have done it before and it worked. Any ideas?
If SDKHooks didn't start up correctly, it should have left some sort of message in the log as to why. Other than that, the error reason should be listed when you do sm exts lists in the console (or sm_rcon sm exts list)
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Andersso
Member
Join Date: Nov 2009
Location: E8 2A 2A 2A 2A
Old 05-25-2012 , 08:36   Re: SDK Hooks 2.1 - Updated 2011-9-10
#1830

Can someone please fix this?

in extension:

PHP Code:
CHECKOFFSET("NetworkStateChanged_m_hGroundEntity"
in gamedata:
PHP Code:
"GroundEntChanged" 
They should have the same name!
Andersso is offline
Closed Thread


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


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