/* Plugin generated by AMXX-Studio */
 
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <engine>
 
#define PLUGIN "Advanced Resetscore"
#define VERSION "1.0"
#define AUTHOR "Silent"
 
#define USE_CC 1
 
#if defined USE_CC
	enum Color
{
	NORMAL = 1, // clients scr_concolor cvar color
	GREEN, // Green Color
	TEAM_COLOR, // Red, grey, blue
	GREY, // grey
	RED, // Red
	BLUE, // Blue
}
 
new TeamName[][] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
}
 
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
	static message[256];
 
	switch(type)
	{
		case NORMAL: // clients scr_concolor cvar color
		{
			message[0] = 0x01;
		}
		case GREEN: // Green
		{
			message[0] = 0x04;
		}
		default: // White, Red, Blue
		{
			message[0] = 0x03;
		}
	}
 
	vformat(message[1], 251, msg, 4);
	message[192] = '^0';
 
	static team, ColorChange, index, MSG_Type;
 
	if(id)
	{
		MSG_Type = MSG_ONE;
		index = id;
	} else {
		index = FindPlayer();
		MSG_Type = MSG_ALL;
	}
 
	team = get_user_team(index);
	ColorChange = ColorSelection(index, MSG_Type, type);
 
	ShowColorMessage(index, MSG_Type, message);
 
	if(ColorChange)
	{
		Team_Info(index, MSG_Type, TeamName[team]);
	}
}
 
ShowColorMessage(id, type, message[])
{
	message_begin(type, get_user_msgid("SayText"), _, id);
	write_byte(id)		
	write_string(message);
	message_end();	
}
 
Team_Info(id, type, team[])
{
	message_begin(type, get_user_msgid("TeamInfo"), _, id);
	write_byte(id);
	write_string(team);
	message_end();
 
	return 1;
}
 
ColorSelection(index, type, Color:Type)
{
	switch(Type)
	{
		case RED:
		{
			return Team_Info(index, type, TeamName[1]);
		}
		case BLUE:
		{
			return Team_Info(index, type, TeamName[2]);
		}
		case GREY:
		{
			return Team_Info(index, type, TeamName[0]);
		}
	}
 
	return 0;
}
 
FindPlayer()
{
	static i;
	i = -1;
 
	while(i <= get_maxplayers())
	{
		if(is_user_connected(++i))
		{
			return i;
		}
	}
 
	return -1;
}
 
#endif
 
#define ADMIN_NEED ADMIN_KICK
 
new cvar_enable;
 
new cvar_showall, cvar_showalladmin;
new cvar_log, cvar_logadmin;
 
public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR);
 
	cvar_enable = register_cvar("ars_enable", "1");
	cvar_showall = register_cvar("ars_showall", "0");
	cvar_showalladmin = register_cvar("ars_showall_admin", "1");
	cvar_log = register_cvar("ars_log", "0");
	cvar_logadmin = register_cvar("ars_log_admin", "1");
 
	register_clcmd("say /rs", "resetscore_player");
	register_clcmd("say /resetscore", "resetscore_player");
	register_clcmd("say !rs", "resetscore_player");
	register_clcmd("say !resetscore", "resetscore_player");
	register_clcmd("resetscore", "resetscore_player");
 
	register_clcmd("amx_resetscore", "resetscore_admin");
	register_clcmd("say amx_resetscore", "resetscore_admin");
}
 
public resetscore_player(id)
{
	if(!get_pcvar_num(cvar_enable))
	return PLUGIN_CONTINUE;
 
	if(!is_user_connected(id))
	return PLUGIN_HANDLED;
 
	set_user_frags(id, 0);
	cs_set_user_deaths(id, 0);
	set_user_frags(id, 0);
	cs_set_user_deaths(id, 0);
 
	new name[32]; get_user_name(id, name, 31);
 
	if(get_pcvar_num(cvar_showall))
	{
		#if defined USE_CC
			ColorChat(0, BLUE, "[D^x04m^x03X^x01]^x03 %s^x04 nul^x01la^x04zt^x03a a s^x04ta^x01ti^x03sz^x01tik^x04aj^x03at.", name);
		#else
			client_print(0, print_chat, "%s nullazta a statisztikajat.", name);
		#endif
	}
	else
	{
		#if defined USE_CC
			ColorChat(id, BLUE, "[DmX]^x04 Si^x03ke^x01rese^x04n nu^x01llaz^x04ta^x03d a st^x01ati^x04szt^x03ika^x04dat.");
		#else
			client_print(id, print_chat, "Sikeresen nullaztad a statisztikadat.");
		#endif
	}
 
	if(get_pcvar_num(cvar_log))
	{
		log_amx("%s nullazta a statisztikajat", name);
	}
	return PLUGIN_HANDLED;
}
 
public resetscore_admin(id)
{
	if(!get_pcvar_num(cvar_enable))
	return PLUGIN_CONTINUE;
 
	if(!is_user_connected(id))
	return PLUGIN_HANDLED;
 
	if(!(get_user_flags(id) & ADMIN_NEED))
	return PLUGIN_HANDLED;
 
	new menu = menu_create("\rValaszd ki a jatekost:", "menu_handler");
	new players[32], pnum, tempid;
	new szName[32], szTempid[10];
	get_players(players, pnum);
	for( new i; i<pnum; i++ )
	{
		tempid = players[i];
		get_user_name(tempid, szName, charsmax(szName));
		num_to_str(tempid, szTempid, charsmax(szTempid));
		menu_additem(menu, szName, szTempid, 0);
	}
	menu_display(id, menu, 0);
 
 
 
 
 
 
	return PLUGIN_HANDLED;
}
 
 
 
 
 
public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}
	new data[6], szName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
	new tempid = str_to_num(data);
	if(is_user_connected(tempid))
	{
		set_user_frags(tempid, 0);
		cs_set_user_deaths(tempid, 0);
		set_user_frags(tempid, 0);
		cs_set_user_deaths(tempid, 0);
 
		new name[32], tempname[32]; get_user_name(id, name, 31); get_user_name(tempid, tempname, 31);
 
		if(get_pcvar_num(cvar_showalladmin))
		{
			#if defined USE_CC
				ColorChat(0, GREEN, "[DmX]^x03 %s^x04 nullazta ^x03%s^x04 statisztikajat.", name, tempname);
			#else
				client_print(0, print_chat, "[DmX] %s nullazta %s statisztikajat.", name, tempname);
			#endif
		}
		else
		{
			#if defined USE_CC
				ColorChat(id, BLUE, "[DmX]^x04 Sik^x01er^x04ese^x03n null^x01azt^x04ad ^x03%s^x04 sta^x03tis^x01zti^x04kaj^x03at.", tempname);
				ColorChat(tempid, BLUE, "[DmX]^x03 %s^x04 nullazta a statisztikadat.", name);
			#else
				client_print(id, print_chat, "[DmX] Sikeresen nullaztad %s statisztikajat.", tempname);
				client_print(tempid, print_chat, "[DmX] %s nullazta a statisztikadat.", name);
			#endif
		}
 
		if(get_pcvar_num(cvar_logadmin))
		{
			log_amx("%s admin nullazta %s jatekos statisztikajat.", name, tempname);
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/