Raised This Month: $170 Target: $400
 42% 

Ham_Killed & TFC


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
teh ORiON
Member
Join Date: Sep 2011
Location: Denmark
Old 08-17-2012 , 09:28   Ham_Killed & TFC
Reply With Quote #1

Hi,

Since hooking CBasePlayer::Killed with Ham_Killed makes TFC(Team Fortress Classic) hang/crash under windows, here is an alternative way using Orpheu which works incase someone out there would need it.

JSON file:
PHP Code:
{
    
"name"      "Killed",
    
"class"     "CBasePlayer",
    
"library"   "mod",
    
"arguments" 
    [
        {
            
"type" "entvars_s *"
        
},
        {
            
"type" "entvars_s *"
        
},
        {
            
"type" "int"
        
}
    ],
    
"indexes" 
    [
        {
            
"os"    "windows",
            
"mod"   "tfc",
            
"value" 14
        
},
        {
            
"os"    "linux",
            
"mod"   "tfc",
            
"value" 16
        
}
    ]

Test plugin:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <orpheu>

public plugin_init()
{
    new 
OrpheuFunction:Player_Killed OrpheuGetFunctionFromClass("player","Killed""CBasePlayer" 
    
OrpheuRegisterHook(Player_Killed,"Killed",OrpheuHookPre
}

public 
Killed(idvictim,idattacker,shouldgib)
{
    new 
victim[32],attacker[32]
    
get_user_name(idvictimvictim31)     
    
get_user_name(idattackerattacker31
    
    
client_print(0,print_chat,"%s was killed by %s",victim,attacker)

Regards,
ORiON.
teh ORiON is offline
Old 08-17-2012, 09:43
dark_style
This message has been deleted by dark_style.
bibu
Veteran Member
Join Date: Sep 2010
Old 08-17-2012 , 17:53   Re: Ham_Killed & TFC
Reply With Quote #2

Nice find and thanks for sharing! There should be especially a thread with updated events for TFC, since most of them don't work.
__________________
Accepting paid work for clans and communities. !Plugins & Models!
Don't hesitate to contact me.
bibu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-17-2012 , 18:54   Re: Ham_Killed & TFC
Reply With Quote #3

It's weird virtual functions doesn't work with Ham, but with Orpheu. -_-
I'm a little curious to know why it happens, will try to investigate.
__________________
Arkshine is offline
teh ORiON
Member
Join Date: Sep 2011
Location: Denmark
Old 08-17-2012 , 22:34   Re: Ham_Killed & TFC
Reply With Quote #4

Quote:
Originally Posted by Arkshine View Post
It's weird virtual functions doesn't work with Ham, but with Orpheu. -_-
I'm a little curious to know why it happens, will try to investigate.
Ok so I also got hooked on finding out why it happens. My initial assumption was that HAM was hooking with bad arguments, and I was right. It turns out that TFC actually take an extra parameter in CBasePlayer::Killed(entvars_s*,entvars_s*,int ). As opposed to CS and possibly other mods that only take two, eg. CBasePlayer::Killed(entvars_s*,int).

I didn't stop here though. I went through HAM's source and changed it so that it could handle the extra parameter, compiled the module and thus ::Killed started working in TFC as expected.

Of course it would seem that HAM would need an update to handle different arguments for the same functions. Anyway there you have it! Bad arguments.

Last edited by teh ORiON; 08-17-2012 at 22:48.
teh ORiON is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-17-2012 , 23:50   Re: Ham_Killed & TFC
Reply With Quote #5

Yes, I've noticed that later too.
Will update here : https://forums.alliedmods.net/showpo...9&postcount=34 ;

It was the case for SendWeaponAnim in CS where one param was removed compared to the original one, which was crashing the thing, so you would need to create Ham_CS_SendWeaponAnim.
__________________

Last edited by Arkshine; 08-17-2012 at 23:51.
Arkshine is offline
teh ORiON
Member
Join Date: Sep 2011
Location: Denmark
Old 08-18-2012 , 08:26   Re: Ham_Killed & TFC
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Yes, I've noticed that later too.
Will update here : https://forums.alliedmods.net/showpo...9&postcount=34 ;

It was the case for SendWeaponAnim in CS where one param was removed compared to the original one, which was crashing the thing, so you would need to create Ham_CS_SendWeaponAnim.
Alright, cool! So it will be added as Ham_TFC_Killed or so?
teh ORiON is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-18-2012 , 08:48   Re: Ham_Killed & TFC
Reply With Quote #7

Yes, Ham_TFC_Killed.

I won't mind if you would test the others TFC functions.
__________________
Arkshine 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 21:18.


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