/* This plugin enables you too quickly enable the console for someone who needs it. 
 * Original code from PetitMort.
 */
 
/* $Id: plugin_console.sma,v 1.0 2001/04/06 yensid $ */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_CONSOLE 8192
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
 
public admin_console(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new Text2[MAX_TEXT_LENGTH];
	new TargetName[MAX_NAME_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (check_user(Data)==1) { 
		get_username(Data,TargetName,MAX_NAME_LENGTH);
		execclient(TargetName, "bind ` toggleconsole");
		execclient(TargetName, "bind ~ toggleconsole");
		execclient(TargetName, "console 1");
		execclient(TargetName, "toggleconsole");
		snprintf(Text, MAX_TEXT_LENGTH, "Activating console for %s.", TargetName);
		selfmessage(Text);
		snprintf(Text2, MAX_TEXT_LENGTH, "Hello, %s!  This is the console!", TargetName);
		message(TargetName, Text2);
		message(TargetName, "Use the ~ key (just left of 1) to toggle this on and off.");
		message(TargetName, "You can type commands here to do many things.");
		message(TargetName, "You'll need to add -console to your shortcut for starting the game to make this permanent.");
		message(TargetName, "Go to http://server.counter-strike.net/server.php?cmd=commands for more info on how to do this.");
        } else {
                selfmessage("Unrecognized user name ");
                selfmessage(Data);
        }
	say_command(User,Command,TargetName);
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("Console Plugin","Help a newbie access the console.",STRING_VERSION);
	plugin_registercmd("admin_console","admin_console",ACCESS_CONSOLE,"admin_console <target> : Enable the console and bind the standard key to it for <target>.");
 
	return PLUGIN_CONTINUE;
}