#include <amxmodx>
#include <dhudmessage>

#define PLUGIN "REKLAMKO"
#define VERSION "3.0"
#define AUTHOR "volkinet"

new gpc_adverttime
new gpc_timemsg

new gpcs_string

new s4et4ik = 0

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	gpc_adverttime = register_cvar("reklamko_time", "60")
	gpc_timemsg = register_cvar("reklamko_time_msg", "10")
	
	gpcs_string = register_cvar("reklamko", "zombie_mod.ru")
}

public plugin_cfg()
{
	set_task(get_pcvar_float(gpc_adverttime), "Advert", random(5000), "", 0, "b" )
}

public Advert()
{
	s4et4ik = 0
	
	set_task(1.0, "showAdvert", 444000, "", 0, "b")
}

public showAdvert(pid)
{
	if(s4et4ik <= get_pcvar_num(gpc_timemsg))
	{
		set_dhudmessage(0, 160, 0, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
		
		static msg[64]
		get_pcvar_string(gpcs_string, msg, sizeof msg -1)
		show_dhudmessage(0, "%s", msg)
		
		s4et4ik++
	}
	else if(task_exists(pid)) remove_task(pid)
}
