Raised This Month: $52 Target: $400
 13% 

Ham Damage (Knife)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-14-2019 , 16:18   Ham Damage (Knife)
Reply With Quote #1

Greetings.

I have a level system which gives xp to "killer" for every kill...
Example if Knife Kill = +5xp if HS knife kill = +7xp.

But I need a plugin that will multiply the knife damage and not affect the Level system, because some plugins I tried... won't give xp after knife kill.

I think RegisterHam(Ham_TakeDamage, ....) should be the solution, but I do not know how to create such thing by myself.
register_event works but, doesnt give XP after knife kill.

Anyone who can help?
Thank you.

Last edited by mentalproblems; 09-14-2019 at 16:23.
mentalproblems is offline
thEsp
Veteran Member
Join Date: Aug 2017
Location: Albania
Old 09-14-2019 , 20:14   Re: Ham Damage (Knife)
Reply With Quote #2

Code:
    /**      * Description:     Usually called whenever an entity takes any kind of damage.      *                  Inflictor is the entity that caused the damage (such as a gun).      *                  Attacker is the entity that tirggered the damage (such as the gun's owner).      * Forward params:  function(this, idinflictor, idattacker, Float:damage, damagebits);      * Return type:     Integer.      * Execute params:  ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);      */     Ham_TakeDamage
Register "Ham_TakeDamage" (pre), check if third parameter (attacker) is carrying a knife and change fourth parameter (SetHamParamFloat) if should.
__________________
Inactive on this forum due to work and busy personal life. Will definitely miss most of y'all, farewell!
thEsp is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-15-2019 , 07:47   Re: Ham Damage (Knife)
Reply With Quote #3

There's no reason for the other plugin not to work unless you're stopping the event in your plugin.
Both "register_event" and "RegisterHam" should work if you do it properly. I suggest the latter.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-15-2019 , 08:06   Re: Ham Damage (Knife)
Reply With Quote #4

Okay, but what should I correct here then so it should work?
Or how should I convert this to RegisterHam?

Here's the source of knife damage.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>

new g_iDamage

public plugin_init() {
    
    
register_plugin("Knife Damage""2.0""alKapone")
    
register_event("Damage""event_damage""be")
    
    
g_iDamage register_cvar("rgc_knife_damage""2")
}

public 
event_damage(id) {
    
    new 
victim id;
    if(!
is_user_connected(victim)) return PLUGIN_CONTINUE
    
new dmg_take read_data(2);
    new 
dmgtype read_data(3);
    new 
Float:multiplier get_pcvar_float(g_iDamage);
    new 
Float:damage dmg_take multiplier;
    new 
health get_user_health(victim);
    
    new 
iWeapIDattacker_id get_user_attacker(victimiWeapID);
    
    if(!
is_user_connected(attacker_id) || !is_user_alive(victim)) {
        return 
PLUGIN_HANDLED
    
}
    
    if(
iWeapID == CSW_KNIFE) {
        
        if(
floatround(damage) >= health) {
            if(
victim == attacker_id) {
                return 
PLUGIN_CONTINUE
            
}
            else {
                
log_kill(attacker_idvictim"knife"0);
            }
            
            return 
PLUGIN_CONTINUE
        
}
        else {
            if(
victim == attacker_id) return PLUGIN_CONTINUE
            
            fakedamage
(victim"weapon_knife"damagedmgtype);
        }
    }
    return 
PLUGIN_CONTINUE
}

stock log_kill(killervictimweapon[],headshot) {
    
user_silentkill(victim);
    
    
message_begin(MSG_ALLget_user_msgid("DeathMsg"), {0,0,0}, 0);
    
write_byte(killer);
    
write_byte(victim);
    
write_byte(headshot);
    
write_string(weapon);
    
message_end();
    
    new 
kfrags get_user_frags(killer);
    
set_user_frags(killerkfrags++);
    new 
vfrags get_user_frags(victim);
    
set_user_frags(victimvfrags++);
    
    return  
PLUGIN_CONTINUE


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

PHP Code:
if(!is_user_connected(attacker_id) || !is_user_alive(victim)) {
        return 
PLUGIN_HANDLED
    

Using "return PLUGIN_HANDLED" in a event will block that event so it won't be captured by any following plugins. Use "PLUGIN_CONTINUE".

Your code is unnecessarily complicated. With "Ham_TakeDamage" you can do the same thing with 20x times less code.
__________________

Last edited by OciXCrom; 09-15-2019 at 08:27.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-16-2019 , 14:59   Re: Ham Damage (Knife)
Reply With Quote #6

Well it doesn't even work now, does anyone have any idea of another knife damage multiplier which fills my criteria too?
mentalproblems is offline
thEsp
Veteran Member
Join Date: Aug 2017
Location: Albania
Old 09-16-2019 , 15:12   Re: Ham Damage (Knife)
Reply With Quote #7

Please consider reading what I said above and tell us what you've tried so far...
__________________
Inactive on this forum due to work and busy personal life. Will definitely miss most of y'all, farewell!
thEsp is offline
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-17-2019 , 08:57   Re: Ham Damage (Knife)
Reply With Quote #8

Well as much as I could possibly understand, I somehow managed to reach this point.
But not sure if this is fully correct. And I would also like to make this work only for RIGHT CLICK Stab.

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"1)
    
    
g_pCvarDamage register_cvar("knife_damage_multiplier""2")
}

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


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

You're registering the event as POST. This means the event has already passed so you can't possibly modify anything. The last argument in "RegisterHam" needs to be 0 if you want to change things (PRE).

Also, in ham you use HAM_IGNORED, HAM_HANDLED, HAM_SUPERCEDE, not PLUGIN_*.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 09-17-2019 , 09:29   Re: Ham Damage (Knife)
Reply With Quote #10

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

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 10:57.


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