#include <amxmodx>
#include <amxmisc>

#define NAME		"AdminChat"
#define VERSION		"1.1 [ZM]"
#define AUTHOR		"Alexander.3"

static sayText
static g_status_sync
static message[192]
static messeg[191]
static msg[6][191]
static names[6][32]
static txt

public plugin_init()
{
	register_plugin(NAME, VERSION, AUTHOR)
	register_clcmd("say", "hook_say")
	sayText = get_user_msgid ("SayText")
	register_message (sayText, "arubaid_duplicated")
	g_status_sync = CreateHudSyncObj()
}

public arubaid_duplicated (msgId, msgDest, receiver)
	return PLUGIN_HANDLED

public hook_say(id)
{
	new strName[191]
	new strText[191]
	new strTextChat[191]
	new name[32]
	new messager[191]
	get_user_name(id, name, 31)
	read_args(message, 191)
	remove_quotes(message)
	
	if(is_user_admin(id))
	{
		switch(txt) 
		{
			case 0:
			{
				get_user_name(id, names[1], 31)
				read_args(msg[1], 191)
				remove_quotes(msg[1])
				format(strText, 191, "%s: %s", names[1], msg[1])
				txt++
			}
			case 1:
			{
				get_user_name(id, names[2], 31)
				read_args(msg[2], 191)
				remove_quotes(msg[2])
				format(strText, 191, "%s: %s^n%s: %s", names[1], msg[1], names[2], msg[2])
				txt++
			}
			case 2:
			{
				get_user_name(id, names[3], 31)
				read_args(msg[3], 191)
				remove_quotes(msg[3])
				format(strText, 191, "%s: %s^n%s: %s^n%s: %s", names[1], msg[1], names[2], msg[2], names[3], msg[3])
				txt++
			}
			case 3:
			{
				get_user_name(id, names[4], 31)
				read_args(msg[4], 191)
				remove_quotes(msg[4])
				format(strText, 191, "%s: %s^n%s: %s^n%s: %s^n%s: %s", names[1], msg[1], names[2], msg[2], names[3], msg[3], names[4], msg[4])
				txt++
			}
			case 4:
			{
				get_user_name(id, names[5], 31)
				read_args(msg[5], 191)
				remove_quotes(msg[5])
				format(strText, 191, "%s: %s^n%s: %s^n%s: %s^n%s: %s^n%s: %s", names[1], msg[1], names[2], msg[2], names[3], msg[3], names[4], msg[4], names[5], msg[5])
				txt++
			}
			case 5:
			{
				msg[1] = msg[2]
				names[1] = names[2]
				msg[2] = msg[3]
				names[2] = names[3]
				msg[3] = msg[4]
				names[3] = names[4]
				msg[4] = msg[5]
				names[4] = names[5]
				get_user_name(id, names[5], 31)
				read_args(msg[5], 191)
				remove_quotes(msg[5])
				format(strText, 191, "%s: %s^n%s: %s^n%s: %s^n%s: %s^n%s: %s", names[1], msg[1], names[2], msg[2], names[3], msg[3], names[4], msg[4], names[5], msg[5])
			}
		}
			
		set_hudmessage(0, 255, 0, 0.05, 0.65, 0, 1.0, 120.0, 0.1, 0.01, -1)
		format(messeg, 900, "%s", strText)
		ShowSyncHudMsg(0, g_status_sync, "%s", messeg)
	}
	else
	{
		format(strName, 191, "%s", name)
		format(strTextChat, 191, "%s", message)
		format(messager, 191, "!t%s: !y%s", strName, strTextChat)
		color_print(0, "%s", messager)
	}
}

/*
public kill(id)
{
	ClearSyncHud(id, g_status_sync)
}
*/

stock color_print(id, const input[], any:...)
{
	new message[192], player, msg_type
    
	vformat(message, 191, input, 3)
	format(message, 191, "^1%s", message)
	replace_all(message, 191, "!g", "^4")
	replace_all(message, 191, "!y", "^1")
	replace_all(message, 191, "!t", "^3")
	message[191] = '^0'
    
	if(id)
	{
		player = id
		msg_type = MSG_ONE_UNRELIABLE
	}
	else
	{
		for(new i = 1; i <= get_maxplayers(); i++)
		{
			if(is_user_connected(i))
			{
				player = i
				break
			}
		}
        
		msg_type = MSG_BROADCAST
	}

	message_begin(msg_type, sayText, _, player)
	write_byte(player)
	write_string(message)
	message_end()

	return 1
}

/* AdminChat [ZM]
* By Alexander.3
* ICQ: 357330340
* Skype: ZombieLite
* WebSite: MakeZone.Ru
*/
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
