/*********************************************************************************

  Auto Game Restart with Countdown Timer
  Version 1.0
  Created by AbeX
  19.02.2008

  Features:
  
    Plugin restarts the game after the time in seconds you have choose.
    Also it shows HUD message with countdown timer in the center of screen.
    After restart the message "LIVE ! LIVE ! LIVE !" will appear in chat.
    Counting starts at game commencing.

  Installation:
  
    Put compiled plugin in the /plugins/ directory.
    Add line containing "auto_rr.amxx" into your plugins.ini file.
    
  Requirements:
  
    None (amxmodx)

  Configuration:
  
    Use autorr_time (float) CVAR in your amxx.cfg change the time after
    that game will be restarted. Example:
    
    autorr_time 10.0 //game will be restarted in 10 seconds, default: 20.0
  
**********************************************************************************/


#include <amxmodx>

new g_Seconds
new g_SecondsCvar

public plugin_init() {
	register_plugin("Auto Game Restart with Countdown Timer", "1.0", "AbeX")
	register_event("TextMsg", "game_commencing", "a", "2=#Game_Commencing")
	g_SecondsCvar = register_cvar("autorr_time","20.0")
}

public game_commencing() {
	if (task_exists(41170))
		remove_task(41170)
	g_Seconds = floatround(get_pcvar_float(g_SecondsCvar))
	new param[32]
	set_task(1.0,"count_rr",41170,param,31,"b",0)	
}

public count_rr() {	
	g_Seconds--;
	set_hudmessage(255, 255, 255, -1.0, 0.4, 0, 6.0, 1.0)
	show_hudmessage(0, "Автоматический рестарт через %d секунд",g_Seconds)	
	if (g_Seconds == 0) {
		server_cmd("sv_restartround 1")	
		client_print(0, print_chat, "Разнесём здесь всё!")
		remove_task(41170)
	}
}
