Raised This Month: $ Target: $400
 0% 

Looking for "Damage done" Plugin, which prints in chat (ESEA-Like)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Mr.Freeman
Senior Member
Join Date: Nov 2013
Location: Canada
Old 12-29-2020 , 17:49   Re: Looking for "Damage done" Plugin, which prints in chat (ESEA-Like)
Reply With Quote #19

Quote:
Originally Posted by ErcouldnT View Post
I don't want to see the players who I didn't interact with. Is there any solution for that? Thanks a lot.
Try this, I added a check to ensure if only displays messages for players that the client damaged or took damage from. Note, I did not test this.

PHP Code:
#include <cstrike>
#include <sourcemod>

#include "include/common.inc"
#include "include/csgo_common.inc"

#pragma semicolon 1
#pragma newdecls required

ConVar g_hEnabled;
ConVar g_hAllowDmgCommand;
ConVar g_hMessageFormat;
ConVar g_ExcludeBots;

int g_DamageDone[MAXPLAYERS+1][MAXPLAYERS+1];
int g_DamageDoneHits[MAXPLAYERS+1][MAXPLAYERS+1];

public 
Plugin myinfo = {
    
name "[CS:GO] Damage printer",
    
author "splewis",
    
description "Writes out player damage on round end or when .dmg is used",
    
version "1.0.0",
    
url "https://github.com/splewis/sm-misc"
};

public 
void OnPluginStart() {
    
g_hEnabled CreateConVar("sm_damageprint_enabled""1""Whether the plugin is enabled");
    
g_hAllowDmgCommand CreateConVar("sm_damageprint_allow_dmg_command""1""Whether players can type .dmg to see damage done");
    
g_hMessageFormat CreateConVar("sm_damageprint_format""--> ({DMG_TO} dmg / {HITS_TO} hits) to ({DMG_FROM} dmg / {HITS_FROM} hits) from {NAME} ({HEALTH} HP)""Format of the damage output string. Avaliable tags are in the default, color tags such as {LIGHT_RED} and {GREEN} also work.");
    
g_ExcludeBots CreateConVar("sm_damageprint_exclude_bots""0""Whether to exclude bots in damage reports");

    
AutoExecConfig();
    
RegConsoleCmd("sm_dmg"Command_Damage"Displays damage done");

    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("player_hurt"Event_DamageDealtEventHookMode_Pre);
    
HookEvent("round_end"Event_RoundEndEventHookMode_Post);
}

static 
void PrintDamageInfo(int client) {
    if (!
IsValidClient(client))
        return;

    
int team GetClientTeam(client);
    if (
team != CS_TEAM_T && team != CS_TEAM_CT)
        return;

    
char message[256];

    
int otherTeam = (team == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T;
    for (
int i 1<= MaxClientsi++) {
        if (
IsValidClient(i) && GetClientTeam(i) == otherTeam && (g_DamageDone[client][i] > || g_DamageDone[i][client] > 0))) {
            if (
g_ExcludeBots.IntValue != && IsFakeClient(i)) {
                continue;
            }

            
int health IsPlayerAlive(i) ? GetClientHealth(i) : 0;
            
char name[64];
            
GetClientName(inamesizeof(name));

            
g_hMessageFormat.GetString(messagesizeof(message));
            
ReplaceStringWithInt(messagesizeof(message), "{DMG_TO}"g_DamageDone[client][i], false);
            
ReplaceStringWithInt(messagesizeof(message), "{HITS_TO}"g_DamageDoneHits[client][i], false);
            
ReplaceStringWithInt(messagesizeof(message), "{DMG_FROM}"g_DamageDone[i][client], false);
            
ReplaceStringWithInt(messagesizeof(message), "{HITS_FROM}"g_DamageDoneHits[i][client], false);
            
ReplaceString(messagesizeof(message), "{NAME}"namefalse);
            
ReplaceStringWithInt(messagesizeof(message), "{HEALTH}"healthfalse);

            
Colorize(messagesizeof(message));
            
PrintToChat(clientmessage);
        }
    }
}

public 
Action Command_Damage(int clientint args) {
    if (
g_hEnabled.IntValue == || g_hAllowDmgCommand.IntValue == 0)
        return;

    if (
IsPlayerAlive(client)) {
        
ReplyToCommand(client"You cannot use that command when alive.");
        return;
    }

    
PrintDamageInfo(client);
}

public 
Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast) {
    if (
g_hEnabled.IntValue == 0)
        return;

    for (
int i 1<= MaxClientsi++) {
        if (
IsValidClient(i)) {
            
PrintDamageInfo(i);
        }
    }
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast) {
    for (
int i 1<= MaxClientsi++) {
        for (
int j 1<= MaxClientsj++) {
            
g_DamageDone[i][j] = 0;
            
g_DamageDoneHits[i][j] = 0;
        }
    }
}

public 
Action Event_DamageDealt(Event event, const char[] namebool dontBroadcast) {
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    
int victim GetClientOfUserId(event.GetInt("userid"));
    
bool validAttacker IsValidClient(attacker);
    
bool validVictim IsValidClient(victim);

    if (
validAttacker && validVictim) {
        
int preDamageHealth GetClientHealth(victim);
        
int damage event.GetInt("dmg_health");
        
int postDamageHealth event.GetInt("health");

        
// this maxes the damage variables at 100,
        // so doing 50 damage when the player had 2 health
        // only counts as 2 damage.
        
if (postDamageHealth == 0) {
            
damage += preDamageHealth;
        }

        
g_DamageDone[attacker][victim] += damage;
        
g_DamageDoneHits[attacker][victim]++;
    }

__________________
Feel Free to PM me about any questions, I'll do my best to help
Mr.Freeman 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 04:39.


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