View Single Post
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-04-2018 , 10:43   Re: Check the number of his murders and how many killed him.
Reply With Quote #3

PHP Code:
#include <sourcemod>

#pragma semicolon 1

int g_iKills[MAXPLAYERS 1];

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_Death);
}

public 
void OnMapEnd()
{
    for (
int i 1<= MaxClientsi++)
    {
        
g_iKills[i] = 0;
    }
}

public 
Action Event_Death(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    
int iAttacker GetClientOfUserId(hEvent.GetInt("attacker"));
    
    if (
IsValidClient(iAttacker))
    {
        
g_iKills[iAttacker]++;
        
        if (
g_iKills[iAttacker] == DesiredAmountOfKills)
        {
            
/* Perform an action here */
        
}
    }
}

stock bool IsValidClient(int iClient)
{
    if (!(
iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
    {
        return 
false;
    }
    
    return 
true;

mug1wara is offline