/*
 * Bailo's Emote/Whisper Script Copyright (C) 1995-2002 The TCW Organization and BAILOPAN
 * http://www.tcwonline.org/
 * If you are an awp hate and would like to use this script, compile it with your name here:
 * "BAILOPAN" killed "[your name here]" with "awp"
*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new STRING_VERSION[MAX_DATA_LENGTH] = "1.00";
new whispern=1;
new emoten=1;
 
#define ACCESS_FUN 8192
 
 
public plugin_init() {
	plugin_registerinfo("Emotions Plugin","Commands for emotions and whispering by BAILOPAN.",STRING_VERSION);
 
	plugin_registercmd("say", "HandleSay", ACCESS_ALL, "/w <player> <message> to send message or /me <action> to display emotion");
	plugin_registercmd("admin_emote", "admin_emote", ACCESS_FUN, "Enable/Disable emotions");
	plugin_registercmd("admin_whisper", "admin_whisper", ACCESS_FUN, "Enable/Disable messaging");
 
	return PLUGIN_CONTINUE;
}
 
public admin_whisper(HLCommand, HLData, HLUserName, UserIndex)
{
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[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_param(Data)==1) {
		selfmessage("Whispering has been turned on!");
		whispern=1;
	} 
	else {
		selfmessage("Whispering has been turned off!");
		whispern=0;
	}
	return PLUGIN_HANDLED;
}
 
public admin_emote(HLCommand, HLData, HLUserName, UserIndex)
{
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[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_param(Data)==1) {
		selfmessage("Emoting has been turned on!");
		emoten=1;
	} 
	else {
		selfmessage("Emoting has been turned off!");
		emoten=0;
	}
	return PLUGIN_HANDLED;
}
 
public HandleSay(HLCommand, HLData, HLUserName, UserIndex) 
{
	new Command[MAX_COMMAND_LENGTH];
	new Speech[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new Emote[MAX_TEXT_LENGTH];
	new Emote2[MAX_TEXT_LENGTH];	
	new Targ[MAX_TEXT_LENGTH];	
	new Mesg[MAX_TEXT_LENGTH];
	new Msg[MAX_TEXT_LENGTH];
 
	convert_string(HLCommand, Command, MAX_COMMAND_LENGTH);
	convert_string(HLData, Speech, MAX_DATA_LENGTH);
	convert_string(HLUserName, User, MAX_NAME_LENGTH);
	strstripquotes(Speech);
	//Length = strlen(Speech);
	if (emoten!=0) {
	if ( (strcasestr(Speech, "fag") != -1) ) {
		slap(User); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/sob") != -1) && (strcasestr(Speech, "server") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s is crying.", User);
		say(Text);
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/own") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s is owning.", User);
		say(Text); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/hateall") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s hate you all.", User);
		say(Text); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/dies") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s dies.", User);
		say(Text);
		slay(User); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/lol") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s laughs out loud.", User);
		say(Text); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "gay awp") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s got killed with an awp and is whining.", User);
		say(Text);
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		slap(User); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/swell") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s swells five times his/her normal size.", User);
		say(Text); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/onion") != -1) ) {
		snprintf(Text, MAX_TEXT_LENGTH, "%s accidentally lobs an onion instead of an HE.", User);
		say(Text); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/trout ") != -1) )  {
		strbreak(Speech, Emote, Emote2, MAX_TEXT_LENGTH);
		snprintf(Text, MAX_TEXT_LENGTH, "%s trout slaps %s.", User, Emote2);
		say(Text); 
		return PLUGIN_HANDLED;
	} else if ( (strcasestr(Speech, "/me ") != -1) )  {
		strbreak(Speech, Emote, Emote2, MAX_TEXT_LENGTH);
		snprintf(Text, MAX_TEXT_LENGTH, "*%s* %s", User, Emote2);
		say(Text);
		return PLUGIN_HANDLED;
	} 
}
	if ( (strcasestr(Speech, "/w ") != -1) ) {
		strbreak(Speech, Targ, Mesg, MAX_TEXT_LENGTH);
		strbreak(Mesg, Targ, Msg, MAX_TEXT_LENGTH);
		//snprintf(Text, MAX_TEXT_LENGTH, "%s", whispern);
		//say(Text);
		if (whispern==1)
		{
			snprintf(Text, MAX_TEXT_LENGTH, "Whisper from %s: %s", User, Msg, Targ);
			//say(Text);
			if (check_user(Targ)==1) 
			{
				messageex(Targ, Text, print_chat);
				return PLUGIN_HANDLED;
			}
		}
	}
 
	return PLUGIN_CONTINUE;
}