Code:
#include <amxmodx>
#include <hamsandwich>
#define PLUGIN "Map End Motd"
#define VERSION "1.0"
#define AUTHOR "author"
enum _:W0W
{
DAMAGE,
HITS
}
new gDamage[33][W0W]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_TakeDamage, "player", "fw_Damage", 1)
register_event("TextMsg", "eReset", "a", "2&#Game_w", "2&#Game_c")
register_message(SVC_INTERMISSION, "message_INTERMISSION")
}
public eReset()
{
for(new i; i < 33; i++)
{
gDamage[i][DAMAGE] = 0
gDamage[i][HITS] = 0
}
}
public client_connect(id)
{
gDamage[id][DAMAGE] = 0
gDamage[id][HITS] = 0
}
public message_INTERMISSION()
{
new iPlayers[32], iNum, iPlayer
new iHighestDamage, iWinnerId
get_players(iPlayers, iNum, "ch")
for(new i; i < iNum; i++)
{
if( gDamage[( iPlayer = iPlayers[i] ) ][DAMAGE] > iHighestDamage)
{
iWinnerId = iPlayer
iHighestDamage = gDamage[iWinnerId][DAMAGE]
}
}
new szMotd[1024]
new szName[32]; get_user_name(iWinnerId, szName, 31)
BuildMotd(szMotd, charsmax(szMotd), szName, iHighestDamage, gDamage[iWinnerId][HITS])
for(new i; i < iNum; i ++)
{
show_motd(iPlayers[i], szMotd, "Best player damage")
}
message_begin(MSG_ALL, SVC_FINALE)
write_string("")
message_end()
//client_cmd(0, "+showscores") // Showscores
return PLUGIN_HANDLED // block
}
public fw_Damage(iVictim, iInflictor, iAttacker, Float:flDamage, iBits)
{
gDamage[iAttacker][DAMAGE] += floatround(flDamage)
gDamage[iAttacker][HITS]++
}
stock BuildMotd(szMotd[], iLen, szName[], iDamage, iHits)
{
new iLeft
iLeft = formatex(szMotd, iLen, "<body bgcolor=^"#000000^">\
<p align=^"center^"><font size=5; color=#FFFF00>Player</font><br>\
<font size=7; color=#0033CC>.: %s :.</font><br>", szName)
iLeft += formatex(szMotd[iLeft], iLen - iLeft, "<font color = #FFB00>Made the most damage in the map with a total of<br>\
<font size = 5; color = #66FFFF>%d</font><font size = 5; color = #FFFF00> Damage</font><br>\
And also made<br></font><font size = 5; color = #66FFFF>%d</font><font size = 5; color = #FFFF00> Hits</font>\
</p>\
</body>", iDamage, iHits)
}
it's supposed to fetch the player with most damage in the map... but I don't think it's taking the right players. It seems to pick random ratio'd players.. not the ones that have been nading/awping and causing a whole lot more damage.
Any way to improve this to show more map stats?
Most Kills
Most Deaths
Best K
Ratio
or even just the top player (kill wise)