Raised This Month: $ Target: $400
 0% 

need simplest code!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
amx_tiger
Junior Member
Join Date: Aug 2012
Old 03-29-2014 , 03:42   Re: need simplest code!
Reply With Quote #2

Not tested, but it should work:

On death:
PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_plugin("Knifed Player""1.0""");
    
    
register_event("DeathMsg""hook_KnifeKill""a""4&kni");
}

public 
plugin_precache()
{
    
precache_sound("misc/my_sound.wav");
}

public 
hook_KnifeKill()
{
    new 
attacker read_data(1);
    new 
victim read_data(2);
    
    if(!
is_user_connected(attacker) || !is_user_connected(victim)) 
        return 
PLUGIN_HANDLED;        
    
    
client_cmd(attacker"spk misc/my_sound.wav");
    
client_cmd(victim"spk misc/my_sound.wav");
    
    return 
PLUGIN_CONTINUE;

On TakeDamage:

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

public plugin_init()
{
    
register_plugin("Knifed Player""1.0""");
    
    
RegisterHam(Ham_TakeDamage"player""hook_TakeDamage"0);
}

public 
plugin_precache()
{
    
precache_sound("misc/my_sound.wav");
}

public 
hook_TakeDamage(idinflictorattackerdamagedamagebits

    if (!
is_user_alive(id) || !is_user_alive(attacker) || get_user_team(id) == get_user_team(attacker))
        return 
HAM_IGNORED;
        
    if ( 
get_user_weapon(attacker) == CSW_KNIFE
    {
        
client_cmd(id"spk misc/my_sound");
        
client_cmd(attacker"spk misc/my_sound");
    }
    
    return 
HAM_IGNORED


Last edited by amx_tiger; 03-29-2014 at 03:43.
amx_tiger is offline
 



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 06:02.


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