#include <amxmisc>
#include <reapi>
new td_max_death;
new td_min_kills;
new td_onlyalive;
new td_norespawn;
new td_reward;
new giDeathCount[TeamName];
public plugin_init()
{
register_plugin("Team Destroy", "24.08.2025", "@emmajule");
register_dictionary("team_destroy.txt");
RegisterHookChain(RG_CSGameRules_PlayerKilled, "CSGameRules_PlayerKilled", true);
RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", true);
RegisterHookChain(RG_RoundEnd, "CSGameRules_RoundTerminating", true);
parse_cfg();
}
public CSGameRules_PlayerKilled(const id, const attacker, const inflictor)
{
giDeathCount[get_member(id, m_iTeam)]++;
}
public CSGameRules_RestartRound()
{
giDeathCount[TEAM_TERRORIST] = 0;
giDeathCount[TEAM_CT] = 0;
}
public CSGameRules_RoundTerminating(WinStatus:status, ScenarioEventEndRound:event, Float:delay)
{
new TeamName:winTeam;
if (status == WINSTATUS_TERRORISTS) {
winTeam = TEAM_TERRORIST;
}
else if (status == WINSTATUS_CTS) {
winTeam = TEAM_CT;
}
else {
return;
}
if (giDeathCount[winTeam] > td_max_death) {
return;
}
new TeamName:opposingTeam = (winTeam == TEAM_CT) ? TEAM_TERRORIST : TEAM_CT;
if (giDeathCount[opposingTeam] < td_min_kills) {
return;
}
for (new i = MaxClients; i > 0; --i)
{
if (!is_user_connected(i)) {
continue;
}
if (get_member(i, m_iTeam) != winTeam) {
continue;
}
if (td_onlyalive && !get_member(i, m_bNotKilled)) {
return;
}
if (td_norespawn && get_member(i, m_iNumSpawns) != 1) {
return;
}
rg_add_account(i, td_reward);
// TD_TAG = [^4Team Destroy^1]
// TD_MSG = Вы получаете^4 %d$^1 за доминирование над вражеской командой в этом раунде!
client_print_color(i, 0, "%l %l", "TD_TAG", "TD_MSG", td_reward);
}
}
parse_cfg()
{
bind_pcvar_num(create_cvar("td_max_death", "0", .description = "Минимальное допустимое количество смертей команды победителей"), td_max_death);
bind_pcvar_num(create_cvar("td_min_kills", "5", .description = "Сколько нужно чтобы умерло в команде врагов"), td_min_kills);
bind_pcvar_num(create_cvar("td_onlyalive", "0", .description = "Награду получают только живые игроки"), td_onlyalive);
bind_pcvar_num(create_cvar("td_norespawn", "0", .description = "Награду получают игроки которые заспавнились только в начале раунда"), td_norespawn);
bind_pcvar_num(create_cvar("td_reward", "1000", .description = "Награда $"), td_reward);
new path[PLATFORM_MAX_PATH];
get_configsdir(path, charsmax(path));
// strcat(path, "/plugins/team_destroy.cfg", charsmax(path));
strcat(path, "/team_destroy.cfg", charsmax(path));
server_cmd("exec %s", path);
server_exec();
}