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

Ham Damage (Knife)


Post New Thread Reply   
 
Thread Tools Display Modes
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-17-2019 , 08:32   Re: Ham Damage (Knife)
Reply With Quote #11

HAM_SUPERCEDE will block the event just like PLUGIN_HANDLED.
HAM_IGNORED is the equivalent of PLUGIN_CONTINUE.

So again, you blocked the entire event for all other plugins by adding HAM_SUPERCEDE in it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-17-2019 , 08:50   Re: Ham Damage (Knife)
Reply With Quote #12

Thanks a lot. I've made it, works perfectly now!

Btw is this: get_user_button(iAttacker) = 1 right click? and 2 left click?

Thanks again!

Last edited by mentalproblems; 09-17-2019 at 08:50.
mentalproblems is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-17-2019 , 09:25   Re: Ham Damage (Knife)
Reply With Quote #13

I don't know. I don't work with magic numbers. There are constants for all available buttons, so use them. Also, that's not how you check a bitsum value.

PHP Code:
if(get_user_button(id) & IN_ATTACK2
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
thEsp
BANNED
Join Date: Aug 2017
Old 09-17-2019 , 14:15   Re: Ham Damage (Knife)
Reply With Quote #14

Quote:
Originally Posted by mentalproblems View Post
Ok thank you.

I'm not sure which one is correct IGNORED or SUPERCEDE
but I put supercede.

Is this okay now?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new g_pCvarDamage

public plugin_init() {
    
register_plugin("Knife Damage Multiplier""1.0""Nevermind")
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage_Post"0)
    
    
g_pCvarDamage register_cvar("rgc_knife_damage""2")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamage// , bitsDamageType
{
    if (!
is_user_alive(iVictim) || !is_user_alive(iAttacker))
        return 
HAM_SUPERCEDE
    
    
if (get_user_weapon(iAttacker) == CSW_KNIFE)
    {
        
SetHamParamFloat(4fDamage get_pcvar_float(g_pCvarDamage)) // not sure if this line is correct
        
return HAM_SUPERCEDE
    
}
    
    return 
HAM_SUPERCEDE

Quote:
Code:
#define HAM_IGNORED     1   /**< Calls target function, returns normal value */
#define HAM_HANDLED     2   /**< Tells the module you did something, still calls target function and returns normal value */
#define HAM_OVERRIDE    3   /**< Still calls the target function, but returns whatever is set with SetHamReturn*() */
#define HAM_SUPERCEDE   4   /**< Block the target call, and use your return value (if applicable) (Set with SetHamReturn*()) */
This does not work at all, so it would be great to post the solution.

Last edited by thEsp; 09-17-2019 at 14:17.
thEsp is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-17-2019 , 20:41   Re: Ham Damage (Knife)
Reply With Quote #15

PHP Code:

#include <amxmodx>
#include <hamsandwich>

new g_pCvarDamage

public plugin_init() 
{
    
register_plugin("Knife Damage Multiplier""1.0""Nevermind")
    
    
//You want to change what happens in take damage, Doing so in post is not possible because at this
    //point the damage is already issued. Passing 0 means pre but you should remove '_Post'. 
    //You can achieve pre by removing the 0 or setting it to 0. Setting to 1 sets it at post.
    //RegisterHam(Ham_TakeDamage, "player", "Fw_TakeDamage_Post", 0)
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage" )
    
    
g_pCvarDamage register_cvar("rgc_knife_damage""2")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamage// , bitsDamageType
{
    
//I think you a re confusing HAM_SUPERCEDE with HAM_IGNORED. If you want normal processing to occur, use HAM_IGNORED
    
if (!is_user_alive(iVictim) || !is_user_alive(iAttacker))
        
//return HAM_SUPERCEDE
        
return HAM_IGNORED
        
    
if (get_user_weapon(iAttacker) == CSW_KNIFE)
    {
        
//This looks fine, it will multiply the issued damage by your cvar. Keep in mind this does not
        //equate to the victims loss in hp since the victims armor can offset the damage taken.
        
SetHamParamFloat(4fDamage get_pcvar_float(g_pCvarDamage)) // not sure if this line is correct
        
        //You should return HAM_HANDLED since you modified something 
        //return HAM_SUPERCEDE
        
return HAM_HANDLED
    
}
    
    
//Again, this will block all damage, you should return HAM_IGNORED
    //return HAM_SUPERCEDE
    
return HAM_IGNORED

__________________

Last edited by Bugsy; 09-17-2019 at 20:42.
Bugsy is offline
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-18-2019 , 12:31   Re: Ham Damage (Knife)
Reply With Quote #16

This code below is fully correct.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new g_pCvarDamage

public plugin_init() {
    
register_plugin("Knife Damage Multiplier""1.0""alKapone")
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage_Post" )
    
    
g_pCvarDamage register_cvar("rgc_knife_damage""3")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamage// , bitsDamageType
{
    if (!
is_user_alive(iVictim) || !is_user_alive(iAttacker))
        return 
HAM_IGNORED
    
    
if (get_user_weapon(iAttacker) == CSW_KNIFE)
    {
        
SetHamParamFloat(4fDamage get_pcvar_float(g_pCvarDamage)) // not sure if this line is correct
        
return HAM_HANDLED
    
}
    
    return 
HAM_IGNORED


AND this code here worked as well, but it also multiplied HE Grenade's damage as well.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new g_pCvarDamage

public plugin_init() {
    
register_plugin("Knife Damage Multiplier""1.0""alKapone")
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage_Post" )
    
    
g_pCvarDamage register_cvar("rgc_knife_damage""3")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamage// , bitsDamageType
{
    if (!
is_user_alive(iVictim) || !is_user_alive(iAttacker))
        return 
HAM_IGNORED
    
    
if (get_user_weapon(iAttacker) == CSW_KNIFE)
    {
        
SetHamParamFloat(4fDamage get_pcvar_float(g_pCvarDamage)) // not sure if this line is correct
        
return HAM_IGNORED
    
}
    
    return 
HAM_IGNORED

mentalproblems is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-18-2019 , 16:06   Re: Ham Damage (Knife)
Reply With Quote #17

get_user_weapon() checks the weapon that the player is holding at the moment when the damage is done. When you throw a HE grenade, it doesn't immediately explode, so the player is probably going to hold the knife again when it explodes and causes damage.

In order to prevent this, you need to check if iAttacker == iInflictor.
__________________

Last edited by OciXCrom; 09-18-2019 at 16:06.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-23-2019 , 05:05   Re: Ham Damage (Knife)
Reply With Quote #18

This does solve that problem?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new g_pCvarDamage

public plugin_init() {
    
register_plugin("Knife Damage Multiplier""1.0""alKapone")
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage_Post" )
    
    
g_pCvarDamage register_cvar("rgc_knife_damage""3")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamage// , bitsDamageType
{
    if (!
is_user_alive(iVictim) || !is_user_alive(iAttacker))
        return 
HAM_IGNORED
    
    
if ((get_user_weapon(iAttacker) == CSW_KNIFE) && (iAttacker == iInflictor))
    {
        
SetHamParamFloat(4fDamage get_pcvar_float(g_pCvarDamage))
        return 
HAM_HANDLED
    
}
    
    return 
HAM_IGNORED


Last edited by mentalproblems; 09-23-2019 at 05:07.
mentalproblems is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-23-2019 , 07:57   Re: Ham Damage (Knife)
Reply With Quote #19

Yes. Did you test?

PS: Not to confuse yourself or anyone else - you named the event "post", but it's actally "pre".
- Pre is called before the damage is applied - here the player hasn't been damaged yet and you can modify or stop the event.
- Post is called after the player took the damage - there's nothing you can do here with the event information. "SetHamParam" will not work.
__________________

Last edited by OciXCrom; 09-23-2019 at 07:58.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-23-2019 , 08:04   Re: Ham Damage (Knife)
Reply With Quote #20

Ok, so I modified it to "Pre".

And added the line "(iAttacker == iInflictor)"

Let's just test if this works then.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new g_pCvarDamage

public plugin_init() {
    
register_plugin("Knife Damage Multiplier""1.0""alKapone")
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage_Pre" )
    
    
g_pCvarDamage register_cvar("rgc_knife_damage""3")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamage// , bitsDamageType
{
    if (!
is_user_alive(iVictim) || !is_user_alive(iAttacker))
        return 
HAM_IGNORED
    
    
if ((get_user_weapon(iAttacker) == CSW_KNIFE) && (iAttacker == iInflictor))
    {
        
SetHamParamFloat(4fDamage get_pcvar_float(g_pCvarDamage))
        return 
HAM_HANDLED
    
}
    
    return 
HAM_IGNORED

Thanks again OciXCrom

Last edited by mentalproblems; 09-23-2019 at 08:04.
mentalproblems 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 02:22.


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