Here it is:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
new cvar_countdown, g_countdown, g_countdown_hud;
enum (+= 100)
{
TASK_COUNTDOWN
}
public plugin_init()
{
register_plugin("Countdown when 1v1", "1.0", "Drakunovu");
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled");
cvar_countdown = register_cvar("countdown_time", "30");
g_countdown_hud = CreateHudSyncObj();
}
public event_new_round()
remove_task(TASK_COUNTDOWN);
public fw_PlayerKilled(victim, attacker, shouldgib)
{
new num;
static players[32];
get_players(players, num, "ah");
switch(num)
{
case 1: remove_task(TASK_COUNTDOWN);
case 2:
{
if (cs_get_user_team(players[0]) == cs_get_user_team(players[1])) return HAM_IGNORED;
g_countdown = get_pcvar_num(cvar_countdown);
set_task(1.0, "countdown", TASK_COUNTDOWN, _, _, "b");
}
}
return HAM_IGNORED;
}
public countdown()
{
set_hudmessage(0, 255, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
ShowSyncHudMsg(0, g_countdown_hud, "Kill each other in %d or slay!", g_countdown);
new number[20];
num_to_word(g_countdown, number, charsmax(number));
client_cmd(0, "spk ^"fvox/%s^"", number); // you can change the sound right here.
g_countdown--;
if (g_countdown < 0)
{
remove_task(TASK_COUNTDOWN);
new num;
static players[32];
get_players(players, num, "ah");
if (num == 2)
{
user_kill(players[0]);
user_kill(players[1]);
}
return;
}
}