#include <amxmodx>
new const g_szUnreal[] = "misc/ut3/unreal.wav";
new g_iKills[33], g_iMaxPlayers;
new g_pNeededKills, g_pAnnounceDelay, g_pAnnounceKills, g_pOnlyAlive, g_pSound, g_pDeathReset;
public plugin_precache()
precache_sound(g_szUnreal);
public plugin_init()
{
register_plugin("Unreal", "1.2", "hleV");
register_dictionary("unreal.txt");
g_pNeededKills = register_cvar("ur_neededkills", "5");
g_pAnnounceDelay = register_cvar("ur_announcedelay", "2.0");
g_pAnnounceKills = register_cvar("ur_announcekills", "1");
g_pOnlyAlive = register_cvar("ur_onlyalive", "1");
g_pSound = register_cvar("ur_sound", "2");
g_pDeathReset = register_cvar("ur_deathreset", "0");
register_event("HLTV", "eventNewRound", "a", "1=0", "2=0");
register_event("DeathMsg", "eventDeath", "a", "1>0");
register_logevent("eventRoundEnd", 2, "1=Round_End");
}
public plugin_cfg()
g_iMaxPlayers = get_maxplayers();
public client_disconnect(iCl)
g_iKills[iCl] = 0;
public eventNewRound()
{
if (!get_pcvar_num(g_pNeededKills))
return;
for (new iCl = 1; iCl <= g_iMaxPlayers; iCl++)
g_iKills[iCl] = 0;
}
public eventDeath(iKiller, iVictim)
{
if (!get_pcvar_num(g_pNeededKills))
return;
if ((iKiller = read_data(1)) == (iVictim = read_data(2)))
if (get_pcvar_num(g_pDeathReset))
g_iKills[iKiller] = 0;
g_iKills[iKiller]++;
if (get_pcvar_num(g_pDeathReset))
g_iKills[iKiller] = 0;
}
public eventRoundEnd(iNeededKills)
{
if (!(iNeededKills = get_pcvar_num(g_pNeededKills)))
return;
new iTop, iKills, iOnlyAlive = get_pcvar_num(g_pOnlyAlive);
for (new iCl = 1; iCl <= g_iMaxPlayers; iCl++)
{
if ((iOnlyAlive && !is_user_alive(iCl)) || !is_user_connected(iCl))
continue;
if (iNeededKills <= g_iKills[iCl] > iKills)
{
iKills = g_iKills[iCl];
iTop = iCl;
}
}
if (iTop)
set_task(get_pcvar_float(g_pAnnounceDelay), "taskAnnounceTop", iTop);
}
public taskAnnounceTop(iCl)
{
if (!get_pcvar_num(g_pNeededKills))
return;
new szName[32], szKills[16];
get_user_name(iCl, szName, 31);
set_hudmessage(random_num(0, 255), random_num(0, 255), random_num(0, 255), -1.0, 0.25, 0, 3.0, 3.0, 0.1, 0.5, -1);
if (get_pcvar_num(g_pAnnounceKills))
formatex(szKills, 15, " (%L)", LANG_PLAYER, "UR_KILLS", g_iKills[iCl]);
show_hudmessage(0, "%L%s", LANG_PLAYER, "UR_UNREAL", szName, szKills);
client_cmd(0, "speak %s", g_szUnreal);
}