#include <amxmodx>
#include <amxmisc>

new configfile[200]

public plugin_init()
{
	register_plugin("Auto Message Displayer","1.0","GHW_Chronic")
	register_cvar("Show_Text_Type","3")
	new configsdir[200]
	get_configsdir(configsdir,199)
	format(configfile,199,"%s/Messages.ini",configsdir)
	new line = file_size(configfile,1) + 1
	for(new i=0;i<=line;i++)
	{
		new read[200]
		new trash
		read_file(configfile,i,read,199,trash)
		remove_quotes(read)
		trim(read)
		if(equali(read,"Hud"))
		{
			display_hud(i)
		}
		if(equali(read,"Text"))
		{
			display_text(i)
		}
	}
}

public display_hud(id)
{
	new read[200]
	new trash
	read_file(configfile,id + 1,read,199,trash)

	if(containi(read,"Red")==0)
	{
		set_hudmessage(255,0,0,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"Green")==0)
	{
		set_hudmessage(0,255,0,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"Blue")==0)
	{
		set_hudmessage(0,0,255,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"Yellow")==0)
	{
		set_hudmessage(255,255,0,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"Orange")==0)
	{
		set_hudmessage(255,128,64,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"Pink")==0)
	{
		set_hudmessage(255,0,128,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"Indigo")==0)
	{
		set_hudmessage(0,255,255,-1.0,0.32,0,6.0,5.0)
	}
	else if(containi(read,"White")==0)
	{
		set_hudmessage(255,255,255,-1.0,0.32,0,6.0,5.0)
	}
	else
	{
		set_hudmessage(255,0,0,-1.0,0.32,0,6.0,5.0)
	}
	new read2[200]
	read_file(configfile,id + 2,read2,199,trash)
	set_task(float(str_to_num(read2)),"display_hud",id)

	new read3[200]
	read_file(configfile,id + 3,read3,199,trash)

	if(get_cvar_num("Show_Text_Type")==2 || get_cvar_num("Show_Text_Type")==3)
	{
		show_hudmessage(0,read3)
	}
	return PLUGIN_HANDLED
}

public display_text(id)
{
	new read[200]
	new trash
	read_file(configfile,id + 1,read,199,trash)
	set_task(float(str_to_num(read)),"display_text",id)

	new read2[200]
	read_file(configfile,id + 2,read2,199,trash)

	if(get_cvar_num("Show_Text_Type")==1 || get_cvar_num("Show_Text_Type")==3)
	{
		client_print(0,print_chat,"%s",read2)
	}
	return PLUGIN_HANDLED
}
