/***************************************************************************\
		    =====================================
		     * || [ZP] Classes In Chat v1.0 || *
		    =====================================

	-------------------
	 *||DESCRIPTION||*
	-------------------

	This plugins adds classes in chat for eg:
	if a person is survivor and he says something then this is what it
	would look like
	[Survivor] Player: Hi I am a survivor
	[Sniper] Player: Hi I am a Sniper
	[Nemesis] Player: Hi I am a Nemesis
	Obviously it will be in colors and so u need the Colorchat include

	---------------
	 *||CREDITS||*
	---------------

	- MeRcyLeZZ ----> For some of the natives
	- K.K.Lv -------> For the country chat plugin
	- My Sister ----> For taking the pics :-D

	------------------
	 *||CHANGE LOG||*
	------------------
	
	v1.0 ====> Initial Release

\***************************************************************************/

#include <amxmodx>
#include <cstrike>
#include <zombieplague>
#include <colorchat>

new players[33][32]
new num[33]

/************************************************************\
|                   [Plugin Initialization]                  |
\************************************************************/


public plugin_init()
{
	// Register the plugin
	register_plugin("[ZP] Classes In Chat", "1.0", "@bdul!")
	
	// Client say commands
	register_clcmd("say", "hook_say")
	register_clcmd("say_team", "hook_team_say")
}

/************************************************************\
|                      [Main Functions]                      |
\************************************************************/


public hook_say(id)
{
	// Process what he is speaking
	new chat[192]
	read_args(chat, 191)
	remove_quotes(chat)
	
	// Get his name
	new name[32]
	get_user_name(id, name, 31)
	
	// Get his team
	new CsTeams:userteam = cs_get_user_team(id)

	// If he has written nothing then return
	if(equal(chat, ""))
		return PLUGIN_HANDLED
	
	// Check if he is alive
	if (is_user_alive(id))
	{
		// He is a zombie
		if (zp_get_user_zombie(id))
		{
			if (zp_get_user_nemesis(id))
			{
				ColorChat(0, RED, "[Nemesis] ^x04%s^x01: %s", name, chat);
			}
			else
			{
				ColorChat(0, RED, "[Zombie] ^x04%s^x01: %s", name, chat);
			}
		}
		// This means he is a human
		else
		{
			if (zp_get_user_survivor(id))
			{
				ColorChat(0, BLUE, "[Survivor] ^x04%s^x01: %s", name, chat);
			}
			else
			{
				ColorChat(0, BLUE, "[Human] ^x04%s^x01: %s", name, chat);
			}
		}
	}
	// He is dead
	else if (!is_user_alive(id) && userteam != CS_TEAM_SPECTATOR)
	{
		ColorChat(0, GREY, "[DEAD] ^x04%s^x01: %s", name, chat);
	}
	// Else he is a spectator
	else 
	{
		ColorChat(0, GREY, "[SPEC] ^x04%s^x01: %s", name, chat);
	}
	return PLUGIN_HANDLED
}

public hook_team_say(id)
{
	// Process his team say
	new chat[192]
	read_args(chat, 191)
	remove_quotes(chat)
	
	// Get his Name
	new name[32], team[32]
	get_user_name(id, name, 31)
	
	// He has written nothing then return
	if(equal(chat, ""))
		return PLUGIN_HANDLED
	
	// Get his team
	new CsTeams:userteam =cs_get_user_team(id)
	
	// He is a zombie
	if (zp_get_user_zombie(id))
	{
		if (get_players(players[id], num[id], _, "TERRORIST"))
		{
			if (zp_get_user_nemesis(id))
				team = "[Nemesis]"
			else
				team = "[Zombie]"
		}
	}
	// Else he is a human
	else
	{
		if (get_players(players[id], num[id], _, "CT"))
		{
			if (zp_get_user_survivor(id))
				team = "[Survivor]"
			else
				team = "[Human]"
		}
	}
	
	// Start the loop
	for (new a = 0; a < num[id]; ++a)
	{
		new i = players[id][a]
		
		// He is alive
		if (is_user_alive(id))
		{
			if (zp_get_user_zombie(id))
				ColorChat(i, RED, "%s^x04(Team Message) %s^x01: %s",team, name, chat);
			else
				ColorChat(i, BLUE, "%s^x04(Team Message) %s^x01: %s",team, name, chat);
		}
		// Else he dead
		else if (!is_user_alive(id) && userteam != CS_TEAM_SPECTATOR)
		{
			ColorChat(i, GREY, "[DEAD]^x04(Team Message) ^x03%s^x01: %s", name, chat);
		}
		// Else he is a spectator
		else
		{
			ColorChat(i, GREY, "[SPEC]^x04(Team Message) ^x03%s^x01: %s", name, chat);
		}
	}
	return PLUGIN_HANDLED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
