#include <amxmodx>
#include <reapi>
public stock const PluginName[] = "Top bomber";
public stock const PluginVersion[] = "0.0.1";
public stock const PluginAuthor[] = "d3m37r4";
new RoundNum;
#define m_iCurrentRound (get_member_game(m_iTotalRoundsPlayed) + 1)
public plugin_init() {
// for AMXX 1.9.0 and older
#if AMXX_VERSION_NUM < 200 || (AMXX_VERSION_NUM == 200 && AMXX_VERSION_LOCAL_REV_NUM < 5412)
register_plugin(PluginName, PluginVersion, PluginAuthor);
#endif
bind_pcvar_num(create_cvar(
.name = "amx_topbomber_round",
.string = "2",
.flags = FCVAR_SERVER,
.description = "Round from which to start determining",
.has_min = true,
.min_val = 0.0
), RoundNum);
RegisterHookChain(RG_CBasePlayer_MakeBomber, "CBasePlayer_MakeBomber_Pre", false);
// RegisterHookChain(RG_CBasePlayer_MakeBomber, "CBasePlayer_MakeBomber_Post", true);
}
public CBasePlayer_MakeBomber_Pre(const id) {
if(RoundNum > m_iCurrentRound) {
return HC_CONTINUE;
}
if(!is_user_connected(id)) {
return HC_CONTINUE;
}
new bestPlayer, Float:maxKdRatio;
for(new player = 1, Float:kdRatio, Float:frags; player <= MaxClients; player++) {
if(!is_user_alive(player)) {
continue;
}
if(get_member(player, m_iTeam) != TEAM_TERRORIST) {
continue;
}
frags = get_entvar(player, var_frags);
if(frags) {
kdRatio = frags/Float:get_member(player, m_iDeaths);
}
if(kdRatio > maxKdRatio) {
maxKdRatio = kdRatio;
bestPlayer = player;
}
}
if(id != bestPlayer) {
SetHookChainArg(1, ATYPE_INTEGER, bestPlayer);
}
return HC_CONTINUE;
}
// public CBasePlayer_MakeBomber_Post(const id) {
// log_amx("Round: %d | CBasePlayer_MakeBomber_Post | player %n (id = %d) was made a bomber", m_iCurrentRound, id, id);
// }