PHP Code:
// Rukia: We need to reset the dmg and hits when a client connects, disconnects, and rounds start
new pug_dmg[33][33]
new pug_hits[33][33]
new pug_lastroundhp[33];
public client_connect(id)
{
arrayset(pug_dmg[id], 0, 33);
arrayset(pug_hits[id], 0, 33);
pug_lastroundhp[id] = floatround(entity_get_float(id, EV_FL_max_health));
}
public client_disconnect(id)
{
for (new i = 0; i < 33; i++)
{
pug_dmg[i][id] = 0;
pug_hits[i][id] = 0;
}
}
public pug_round_start()
{
#if defined RESET_DELAY
set_task( RESET_DELAY, "allowdmgreset" )
#else
allowdmgreset()
#endif
allowdmg = true
}
public pug_round_start_failed()
{
#if defined RESET_DELAY
set_task( RESET_DELAY, "allowdmgreset" )
#else
allowdmgreset()
#endif
allowdmg = true
}
// Rukia: Assume that the mod specific plugin has loaded the correct module, or provided this for us
public client_damage ( attacker, victim, amount, wpnindex, hitplace, TA )
{
//if (attacker == victim) return;
pug_dmg[attacker][victim] += amount
pug_hits[attacker][victim] += 1
pug_lastroundhp[victim] -= amount;
}
#include <yap_aux>
public cmd_hpall(id)
{
if(is_user_alive(id) && id != 0) { pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED"); }
else
{
static Players[32], name[32]
new playerCount, i, player
get_players(Players, playerCount, "ah")
for (i=0; i<playerCount; i++)
{
player = Players[i]
get_user_name(player,name,31)
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_HP",name,pug_lastroundhp[player],get_user_armor(player))
}
}
return PLUGIN_HANDLED
}
public cmd_hpteam(id)
{
if(is_user_alive(id) && id != 0) { pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED"); }
else
{
static Players[32], name[32]
new playerCount, i, player
get_players(Players, playerCount, "ah")
new teamid = pug_get_client_team(id)
for (i=0; i<playerCount; i++)
{
player = Players[i]
if(teamid == pug_get_client_team(player) ) continue;
get_user_name(player,name,31)
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_HP",is_user_alive( player ) ? pug_lastroundhp[player] : 0, get_user_armor(player), name)
}
}
return PLUGIN_HANDLED
}
And put this on the "allowdmgreset" function:
PHP Code:
for(new i = 0; i < 33; ++i)
pug_lastroundhp[id] = 100;
You can refine this code to get the best result, tweak it until you find it perfect.
EDIT: Also, if you're going to use this code, I strongly recommend you to use the value of `mp_freezetime' instead of `RESET_DELAY' to reset last round info.