#include <amxmodx>
#include <reapi>
new g_damag[33][2];
public plugin_init() {
register_plugin("Best damage", "0.2", "maxee");
register_clcmd("say /dmg","damag");
RegisterHookChain(RG_RoundEnd, "HC_RoundEnd", true);
RegisterHookChain(RG_CBasePlayer_TakeDamage, "HC_CBasePlayer_TakeDamage_Pre", true);
}
public client_disconnected(id)
{
g_damag[id][0] = 0;
g_damag[id][1] = 0;
}
public HC_RoundEnd()
{
new max_dam = 0;
new max_dam_id = 0;
for(new i = 1; i < 33; i++)
{
for(new j = 1; j < 33; j++)
{
if( !is_user_connected(j) )
continue;
if( max_dam <= g_damag[j][0] )
{
max_dam = g_damag[j][0];
max_dam_id = j;
}
}
}
new name[33];
get_user_name(max_dam_id, name, 32);
client_print_color(0, print_team_red, "^4* ^3Best player of the round: ^4%s ^1[^3%d hits ^1= ^3%d dmg^1]", name, g_damag[max_dam_id][1], g_damag[max_dam_id][0]);
g_damag[max_dam_id][0] = 0;
g_damag[max_dam_id][1] = 0;
}
public HC_CBasePlayer_TakeDamage_Pre(victim, weapon, attacker, Float:fDamage, damagebits)
{
if( get_member(attacker, m_iTeam) == CS_TEAM_T && get_member(victim, m_iTeam) == CS_TEAM_CT )
{
g_damag[attacker][0] += floatround(fDamage,floatround_round);
g_damag[attacker][1]++;
}
else if( get_member(attacker, m_iTeam) == CS_TEAM_CT && get_member(victim, m_iTeam) == CS_TEAM_T )
{
g_damag[attacker][0] += floatround(fDamage,floatround_round);
g_damag[attacker][1]++;
}
}
public damag(id)
{
new max_dam = 0;
new max_dam_id = 0;
for(new i = 1; i < 33; i++)
{
for(new j = 1; j < 33; j++)
{
if( !is_user_connected(j) )
continue;
if( max_dam < g_damag[j][0] )
{
max_dam = g_damag[j][0];
max_dam_id = j;
}
}
}
new name[33];
get_user_name(max_dam_id,name, 32);
client_print_color(0, print_team_red, "^4* ^3Best player of the map: ^4%s ^1[^3%d hits ^1= ^3%d dmg^1]", name, g_damag[max_dam_id][1], g_damag[max_dam_id][0]);
}