/*This plugin lets you turn off the ability for
people to use chat messages.  I don't know why
anyone whould ever want to do this but someone in
the forums wanted.
 
Created by gnugy August 29/2001*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_TOGGLECHAT ACCESS_RCON
 
new STRING_VERSION[MAX_DATA_LENGTH] = "1.00";
 
/*State of chatmodee, 1 for on 0 for off
default is on, change to 0 to make default off*/
new CHAT_STATE = 1;
 
public admin_togglechat(HLCommand, HLData, HLUserName, UserIndex) {
	if (CHAT_STATE == 0) {
		CHAT_STATE = 1;
		say("Chat has been turned on");
	} else {
		CHAT_STATE = 0;
		say("Chat has been turned off");
	}
	return PLUGIN_HANDLED;
}
 
public HandleSay(HLCommand, HLData, HLUserName, UserIndex) {
	new Name[MAX_NAME_LENGTH];
 
	convert_string(HLUserName, Name, MAX_NAME_LENGTH);	
 
	if (CHAT_STATE == 0) {
		messageex(Name, "You are currently not allowed to chat", print_chat);
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;
}
 
public plugin_init() {
	plugin_registerinfo("Admin Toggle Chat", "Allows admin with RCON to turn off chating", STRING_VERSION);
	plugin_registercmd("admin_togglechat", "admin_togglechat", ACCESS_TOGGLECHAT, "admin_togglechat : Turns chatting on or off");
	plugin_registercmd("say", "HandleSay", ACCESS_ALL);
//	plugin_registercmd("say_team", "HandleSay", ACCESS_ALL);
 
	return PLUGIN_CONTINUE;
}