
/* AMX Mod script. 
* 
* Use say commands to chat and send messages, by Sir 
* some parts by JustinHoMi 
* 
* say <parameter> <text> 
* For coloured messages say sentence with one (side text), two (center text) 
* or three (bottom text) @ at the beginning. To get text coloured use 
* r,g,b,y,a, or p after @. 
*
* say_team <parameter> <text> 
* For chat between admins use say_team command with @ at the beginning. 
* If player wants to say something to an admin he should say his text with 
* @ at the beginning.
*/  

#include <amxmod> 

new colors[7][3] = {{255,255,255},{200,0,0},{0,200,0},{0,0,200},{200,200,0},{200,0,200},{0,200,200}} 
new Float:pos[4][2] = {{0.0,0.0},{0.05,0.6},{-1.0,0.3},{-1.0,0.8}} 

public say_all(id) {
	if (!(get_user_flags(id)&ADMIN_CHAT))	return PLUGIN_CONTINUE
	new said[6]
	read_argv(1,said,5)
	new i=0
	while (said[i]=='@')
		i++
	if (i==0||i>3) return PLUGIN_CONTINUE
	new message[192], a = 0
	read_argv(1,message,191)
	switch(said[i]){
		case 'r': a = 1
		case 'g': a = 2
		case 'b': a = 3
		case 'y': a = 4
		case 'm': a = 5
		case 'c': a = 6
	}
	set_hudmessage(colors[a][0], colors[a][1], colors[a][2], pos[i][0], pos[i][1], 0, 6.0, 6.0, 0.5, 0.15, i)
	show_hudmessage(0,message[i+1])
	return PLUGIN_HANDLED
}

public say_team(id) {
	new said[3]
	read_argv(1,said,2)
	if (said[0]!='@') return PLUGIN_CONTINUE
	new message[192]
	read_argv(1,message,191)
	new name[32]
	get_user_name(id,name,31)
	new players[32], inum
	get_players(players,inum)
	format(message,191,"(ADMINS) %s :  %s",name,message[1])
	for(new i=0; i<inum; ++i)
		if (get_user_flags(players[i]))
			client_print(players[i],print_chat,message)
	return PLUGIN_HANDLED
}

public plugin_init() {
	register_plugin("Say Chat","0.6","Sir")
	register_clcmd("say","say_all")
	register_clcmd("say_team","say_team")
	return PLUGIN_CONTINUE
}

