View Single Post
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-05-2023 , 18:57   Re: Tank Damage Announce by griffin
Reply With Quote #36

Quote:
Originally Posted by Mika Misori View Post
Does anyone know a plugin that report the damage done to tank into the chat, but does not count the damage from molotov?

I found only this plugin: https://forums.alliedmods.net/showthread.php?t=329865
but it is for statistics, which is displayed on transition to the next map.

I want to know who really shot/hit tank and how much real damage was done by player's guns/melee, but not the damage from someone threw a molo, after which all just run away from tank.

Untested

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

#define PLUGIN_VERSION "1.0"

int g_iPlayerTankDamage [MAXPLAYERS+1][MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
HookEvent("player_hurt"Event_PlayerHurtEventHookMode_Post);
    
    
HookEvent("tank_killed"Event_TankKilledEventHookMode_Post);
    
HookEvent("player_death"Event_TankKilledEventHookMode_Post);
}

void Event_PlayerHurt(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid"));
    if (!
victim || !IsPlayerTank(victim) || IsTankInDeathAnimation(victim)) return;
    
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    if (!
attacker || !IsClientInGame(attacker) || GetClientTeam(attacker) != 2) return;
    
    
int iDamage event.GetInt("dmg_health");
    
int iType event.GetInt("type");
    
    
//This line to uncount fire damage, if it doesnt work, you need to check the fire damage type and block it, I cant access the game atm
    
if(IsFireDamage(iType)) iDamage 0;
    
    
g_iPlayerTankDamage[attacker][victim] += iDamage;
}

void Event_TankKilled(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid"));
    if (!
victim || !IsPlayerTank(victim)) return;
    
    
PrintTankDamageStatus(victim);
}

//This part was modified from > https://forums.alliedmods.net/showthread.php?p=2559282
void PrintTankDamageStatus(int victim)
{
    
int iSurvivoriPlayer[MAXPLAYERS+1][2];
    for (
int i 1<= MaxClientsi++)
    {
        if (
g_iPlayerTankDamage[i][victim] <= || !IsClientInGame(i) || GetClientTeam(i) != 2) continue;
        
iPlayer[iSurvivor][0] = i;
        
iPlayer[iSurvivor][1] = g_iPlayerTankDamage[i][victim];
        
iSurvivor++;
    }
    
    if (
iSurvivor == 0) return;
    
SortCustom2D(iPlayeriSurvivorSortDescending);

    
char sMessage[256];
    for (
int iiSurvivori++)
    {
        
int attacker iPlayer[i][0];
        
char sTemp[64];
        
        
Format(sTempsizeof(sTemp), "\x01%s \x05%N \x01(\x04%d \x01dmg)", (", " ""), attackerg_iPlayerTankDamage[attacker][victim]);
        
StrCat(sMessagesizeof(sMessage), sTemp);
        
g_iPlayerTankDamage[attacker][victim] = 0;
    }
    
    
PrintToChatAll("\x04[Notify] \x03%N \x01killed: %s\x01."victimsMessage);
}

int SortDescending(int[] elem1int[] elem2, const int[][] array, Handle hndl)
{
    return 
elem2[0] - elem1[0];
}

bool IsPlayerTank(int client)
{
    return (
IsClientInGame(client) && GetClientTeam(client) == && GetEntProp(clientProp_Send"m_zombieClass") == 8);
}

bool IsTankInDeathAnimation(int client)
{
    return (
GetEntProp(clientProp_Send"m_isIncapacitated"1) > || GetEntProp(clientProp_Send"m_nSequence") >= 65 || !IsPlayerAlive(client));
}

bool IsFireDamage(int damagetype)
{
    return (
damagetype == DMG_BURN || damagetype == DMG_PREVENT_PHYSICS_FORCE DMG_BURN || damagetype == DMG_DIRECT DMG_BURN);

__________________

Last edited by alasfourom; 06-07-2023 at 16:28.
alasfourom is offline