Raised This Month: $ Target: $400
 0% 

Ham not work with Engine?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-12-2012 , 00:20   Ham not work with Engine?
Reply With Quote #1

So i have this mod that makes your screen move around (Brass Knuckles by Cheap_Suit if you remember it) and i rewrote a bit of it. In my version i use Ham_TakeDamage isntead of stock registered "Damage" but when i use the Ham functions, it doesn't work. Any ideas as to why this is? Does Ham just not work properly with Engine? Is there another way to do it so i can still use Ham?

My ham function: commented out as debugging
PHP Code:
ublic event_hamDamage(victimIDi_weaponattackerIDFloat:flDamageiDmgBits)
{
    new 
bool:alive = ( is_user_alive(victimID) || is_user_alive(attackerID) )
    new 
bool:connected = ( is_user_connected(victimID) || is_user_connected(attackerID) )
    if(!
alive || !connected)
        return 
HAM_HANDLED
        
    
if(i_weapon != CSW_KNIFE || !g_bknuckles[attackerID])
        return 
HAM_HANDLED
        
    
    
//new Float:Random_Float[3]    // Punch View Vector
    
    
if(get_pcvar_num(frags_pcvar) == 0)
    {
        
//for(new i = 0; i < 3; i++) 
        //    Random_Float[i] = random_float(100.0, 150.0)
    
}
    else 
    {
        new 
aLevel getLevel(attackerID// level of attacker
        
switch(aLevel)
        {
        
//case 0:    // Low knock
        //{
        //    for(new i = 0; i < 3; i++)     // sets the Punch View vector
        //        Random_Float[i] = random_float(25.0, 75.0)
        //}
        
case 4:
        {
        
//    for(new i = 0; i < 3; i++) 
        //        Random_Float[i] = random_float(100.0, 150.0)
                
        //    SetHamParamFloat(4, flDamage + get_pcvar_num(strength_pcvar))
        
}
        
// case 5: will have powers enabled
    #if defined INSTAKILL
        
case INSTAKILL:
        {
            
SetHamParamFloat(4110.0)
            
client_cmd(attackerIDINSTAKILL_SOUND)
            
client_cmd(victimIDINSTAKILL_SOUND)
        }
    
#endif
        
default:// normal power 
        
{
        
//    if(aLevel > 4)
        //        SetHamParamFloat(4, flDamage + 7)
        //    for(new i = 0; i < 3; i++) 
        //        Random_Float[i] = random_float(100.0, 150.0)
        
}
        } 
    }
    new 
Float:Random_Float[3]
    for(new 
03i++)
        
Random_Float[i] = random_float(100.0150.0)
    
Punch_View(victimIDRandom_Float)

    return 
HAM_HANDLED

And here is the working code:
Spoiler
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-12-2012 , 01:05   Re: Ham not work with Engine?
Reply With Quote #2

Your code in the handler is just wrong, and that variable is not the weapon ID, even though the documentation says so.

Code:
#include <amxmodx> #include <hamsandwich> new gMaxPlayers; public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "FwdTakeDamagePlayerPost", 1);         gMaxPlayers = get_maxplayers(); } public FwdTakeDamagePlayerPost(victim, inflictor, attacker, Float:damage, damageBits) {     if(inflictor == attacker     && (1 <= attacker <= gMaxPlayers)     && attacker != victim     && g_bknuckles[attacker]     && is_user_alive(victim)     && get_user_weapon(attacker) == CSW_KNIFE) {          // attacker hit victim with brass knuckles and victim is still alive     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-12-2012 , 01:27   Re: Ham not work with Engine?
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Your code in the handler is just wrong, and that variable is not the weapon ID, even though the documentation says so.

Code:
#include <amxmodx> #include <hamsandwich> new gMaxPlayers; public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "FwdTakeDamagePlayerPost", 1);         gMaxPlayers = get_maxplayers(); } public FwdTakeDamagePlayerPost(victim, inflictor, attacker, Float:damage, damageBits) {     if(inflictor == attacker     && (1 <= attacker <= gMaxPlayers)     && attacker != victim     && g_bknuckles[attacker]     && is_user_alive(victim)     && get_user_weapon(attacker) == CSW_KNIFE) {          // attacker hit victim with brass knuckles and victim is still alive     } }
what the hell is the inflictor, then?

-testing your code now-

EDIT: and what about grenade damage that is delt while the attacker has a knife out?
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-12-2012 at 01:30.
Liverwiz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-12-2012 , 01:28   Re: Ham not work with Engine?
Reply With Quote #4

When a weapon is involved, inflictor is equal to attacker, when it is another entity, such as a grenade, then inflictor is the nade entity index.
Also, if you plain to change params, hook the function before it actually happen.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-12-2012 , 01:33   Re: Ham not work with Engine?
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
When a weapon is involved, inflictor is equal to attacker, when it is another entity, such as a grenade, then inflictor is the nade entity index.
Also, if you plain to change params, hook the function before it actually happen.
that explains all my above questions. Thank you.
and i do have it hooked as post=0
I did get that much from the documentation.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 18:47.


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