Hello, why plugin do not show acc %? When round end always shows 0% acc. Maybe can help? Thanks.
Code:
#include <amxmodx>
#include <amxmisc>
#include <csstats>
#define MIN_KILLS 1
new Kills[33];
new Headshots[33];
public plugin_init()
{
register_plugin("Best", "1.0", "eV");
register_event("HLTV", "OnHltv", "a", "1=0", "2=0");
register_event("DeathMsg", "OnDeathMsg", "a");
register_logevent("OnRoundEnd", 2, "1=Round_End");
}
public client_disconnected(id)
Kills[id] = Headshots[id] = 0;
public OnHltv()
{
arrayset(Kills, 0, sizeof Kills);
arrayset(Headshots, 0, sizeof Headshots);
}
public OnDeathMsg()
{
new id = read_data(1);
if (!is_user_connected(id))
return;
Kills[id]++;
if (read_data(3))
Headshots[id]++;
}
public OnRoundEnd()
{
static stats[8]
new players[32], num;
get_players(players, num);
if (!num)
return;
new best = players[0];
for (new i = 1, id; i < num; i++)
{
id = players[i];
if (Kills[id] > Kills[best] || (Kills[id] == Kills[best] && Headshots[id] > Headshots[best]))
best = id;
}
if (Kills[best] < MIN_KILLS) // Minimum amount of kills
return;
new name[32];
get_user_name(best, name, charsmax(name));
client_print(0, print_chat, "* Best is %s!", name);
client_print(0, print_chat, "* He killed %d players, including %d headshots.", Kills[best], Headshots[best]);
client_print(0, print_chat, "* ACC: %2.0f%%", accuracy(stats));
}
stock Float:accuracy(stats[8])
{
if(!stats[4])
return ( 0.0 );
new Float:result
result = 100.0 * float( stats[5] ) / float( stats[4] );
return (result > 100.0) ? 100.0 : result
}