AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hook when client kill someone? (https://forums.alliedmods.net/showthread.php?t=131917)

Jelle 07-10-2010 06:28

hook when client kill someone?
 
How do I hook when a client kills someone else. I do not want deathmsg, since that is when the person itself dies. I want to know when the client is killing someone...

ConnorMcLeod 07-10-2010 06:50

Re: hook when client kill someone?
 
DeathMsg is fine though.

PHP Code:

#include <amxmodx>

#define FIRST_PLAYER_ID    1

new g_iMaxPlayers
#define IsPlayer(%1)    ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

enum
{    
    
DeathMsg_KillerID 1// byte
    
DeathMsg_VictimID// byte
    
DeathMsg_IsHeadshot// byte
    
DeathMsg_TruncatedWeaponName // string
}

public 
plugin_init()
{
    
register_event("DeathMsg""Event_DeathMsg""a")

    
g_iMaxPlayers get_maxplayers()
}

//http://wiki.amxmodx.org/Half-Life_1_Game_Events#DeathMsg
public Event_DeathMsg()
{
    new 
iKiller read_data(DeathMsg_KillerID)
    if( 
IsPlayer(iKiller) )
    {
        new 
iVictim read_data(DeathMsg_VictimID)
        if( 
iKiller != iVictim )
        {
            new 
szKillerName[32], szVictimeName[32]
            
get_user_name(iKillerszKillerNamecharsmax(szKillerName))
            
get_user_name(iVictimszVictimeNamecharsmax(szVictimeName))
            new 
szWeaponName[10]
            
read_argv(DeathMsg_TruncatedWeaponNameszWeaponNamecharsmax(szWeaponName))
            
client_print(0print_chat"%s killed %s with %s %s"
                                
szKillerName
                                        
szVictimeName
                                            
szWeaponName
                                                
read_data(DeathMsg_IsHeadshot) ? "with HeadShot" "")
            
// iKiller killed iVictim
        
}
    }



Jelle 07-10-2010 08:05

Re: hook when client kill someone?
 
Thank you. That helped!


All times are GMT -4. The time now is 07:09.

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