/*
* [Jedi]-Baron-'s Fun Kill Announcer LogD Plugin - October 18, 2001
* Based on the Knife kill code by Bud-frog (my hero)
*
* Announces Knife and Nade fragging along with Suicides :)
*/
 
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_CONSOLE 131072
 
new STRING_VERSION[MAX_DATA_LENGTH] = "v1";
 
public logd_funkill(HLCommand,HLData,HLUserName,UserIndex)
{
	new sID1[MAX_NUMBER_LENGTH];
	new sID2[MAX_NUMBER_LENGTH];
 
	new Weapon[MAX_NAME_LENGTH];
	new Data[MAX_DATA_LENGTH];
 
	convert_string(HLData, Data, MAX_DATA_LENGTH);
	strsplit(Data, " ", sID1, MAX_NUMBER_LENGTH, sID2, MAX_NUMBER_LENGTH, Weapon, MAX_NAME_LENGTH);
 
	if( strcmp( Weapon, "knife") == 0 )
	{
		new Message[MAX_TEXT_LENGTH];
		new NameA[MAX_NAME_LENGTH];
		new NameV[MAX_NAME_LENGTH];
 
		new iRand = random(10);
		new iID1 = strtonum(sID1);
		new iID2 = strtonum(sID2);
 
 
		if( !playerinfo(iID1,NameA,MAX_NAME_LENGTH) ) {
			return PLUGIN_FAILURE;
		}
		if( !playerinfo(iID2,NameV,MAX_NAME_LENGTH) ) {
			return PLUGIN_FAILURE;
		}
 
		switch( iRand )
		{
			case 0: snprintf( Message, MAX_TEXT_LENGTH, "%s oWneD %s with a knife!!!", NameA, NameV );
			case 1: snprintf( Message, MAX_TEXT_LENGTH, "%s, you were just n00b-ized by %s", NameV, NameA );
			case 2: snprintf( Message, MAX_TEXT_LENGTH, "%s, you should consider changing pastimes.^nI'd recommend either gardening or under water basket weaving.", NameV );
			case 3: snprintf( Message, MAX_TEXT_LENGTH, "%s taught %s what a close shave really is!", NameA, NameV );
			case 4: snprintf( Message, MAX_TEXT_LENGTH, "%s got sLiCeD and DiCeD by %s", NameV, NameA );
			case 5: snprintf( Message, MAX_TEXT_LENGTH, "Knife Kill by %s^nOoga Shaka!!!", NameA);
			case 6: snprintf( Message, MAX_TEXT_LENGTH, "%s is now ground beef.", NameV );
			case 7: snprintf( Message, MAX_TEXT_LENGTH, "%s, the other white meat.", NameV );
			case 8: snprintf( Message, MAX_TEXT_LENGTH, "%s, have you no honor?", NameV );
			case 9: snprintf( Message, MAX_TEXT_LENGTH, "%s, is that a knife in your back?", NameV );
			default: snprintf( Message, MAX_TEXT_LENGTH, "%s oWneD %s with a knife!!!", NameA, NameV );
		}
		printMessage( Message );
 
	}
 
	if( strcmp( Weapon, "grenade") == 0 )
	{
		new Message[MAX_TEXT_LENGTH];
		new NameA[MAX_NAME_LENGTH];
		new NameV[MAX_NAME_LENGTH];
 
		new iRand = random(9);
		new iID1 = strtonum(sID1);
		new iID2 = strtonum(sID2);
 
 
		if( !playerinfo(iID1,NameA,MAX_NAME_LENGTH) ) {
			return PLUGIN_FAILURE;
		}
		if( !playerinfo(iID2,NameV,MAX_NAME_LENGTH) ) {
			return PLUGIN_FAILURE;
		}
 
		switch( iRand )
		{
			case 0: snprintf( Message, MAX_TEXT_LENGTH, "%s tried catch the nade and throw it back!", NameV );
			case 1: snprintf( Message, MAX_TEXT_LENGTH, "%s became a shrapnel shield for his teammates", NameV );
			case 2: snprintf( Message, MAX_TEXT_LENGTH, "%s, just keep telling yourself:^n Nades are my friend and would never hurt me. . . ", NameV );
			case 3: snprintf( Message, MAX_TEXT_LENGTH, "B O O M!!! Did that tickle, %s?", NameV );
			case 4:	snprintf( Message, MAX_TEXT_LENGTH, "%s:^n See boys, that is how you use the nade!", NameA );
			case 5: snprintf( Message, MAX_TEXT_LENGTH, "Sitting on a grenade helps no one, %s,^n but it looked good!", NameV);
			case 6:	snprintf( Message, MAX_TEXT_LENGTH, "%s wipes pieces of %s off his face . . .", NameA, NameV );
			case 7:	snprintf( Message, MAX_TEXT_LENGTH, "%s: Oops, I guess that was not a flashbang.", NameV );
			case 8:	snprintf( Message, MAX_TEXT_LENGTH, "Watching your teammate get blown apart^n in front of you is never good for moral." );
			default: snprintf( Message, MAX_TEXT_LENGTH, "%s tried catch the nade and throw it back!", NameV );
		}
		printMessage( Message );
 
	}
	return PLUGIN_HANDLED;
}
 
public logd_suicide(HLCommand,HLData,HLUserName,UserIndex)
{
	new sID1[MAX_NUMBER_LENGTH];
 
	new Weapon[MAX_NAME_LENGTH];
	new Data[MAX_DATA_LENGTH];
 
	convert_string(HLData, Data, MAX_DATA_LENGTH);
	strsplit(Data, " ", sID1, MAX_NUMBER_LENGTH, Weapon, MAX_NAME_LENGTH);
 
	if( strcmp( Weapon, "worldspawn") == 0 )
	{
		new Message[MAX_TEXT_LENGTH];
		new NameV[MAX_NAME_LENGTH];
 
		new iRand = random(7);
		new iID1 = strtonum(sID1);
 
 
		if( !playerinfo(iID1,NameV,MAX_NAME_LENGTH) ) {
			return PLUGIN_FAILURE;
		}
 
		switch( iRand )
		{
			case 0: snprintf( Message, MAX_TEXT_LENGTH, "%s, suicide is NOT the answer!!", NameV );
			case 1: snprintf( Message, MAX_TEXT_LENGTH, "Watch that first step, %s it is a doozey", NameV );
			case 2: snprintf( Message, MAX_TEXT_LENGTH, "Don't worry, %s.  I know your losing,^n but it will be all right.", NameV );
			case 3: snprintf( Message, MAX_TEXT_LENGTH, "%s committed suicide because^n he was so upset about letting his team down!", NameV );
			case 4:	snprintf( Message, MAX_TEXT_LENGTH, "%s, it only hurts when you hit the ground.", NameV );
			case 5: snprintf( Message, MAX_TEXT_LENGTH, "%s:^n life is just not worth living anymore!", NameV);
			case 6:	snprintf( Message, MAX_TEXT_LENGTH, "Paratrooping works better with a parachute,^n %s.", NameV );
			default: snprintf( Message, MAX_TEXT_LENGTH, "%s, suicide is NOT the answer!!", NameV );
		}
		printMessage( Message );
 
	}
 
	if( strcmp( Weapon, "grenade") == 0 )
	{
		new Message[MAX_TEXT_LENGTH];
		new NameV[MAX_NAME_LENGTH];
 
		new iRand = random(5);
		new iID1 = strtonum(sID1);
 
 
		if( !playerinfo(iID1,NameV,MAX_NAME_LENGTH) ) {
			return PLUGIN_FAILURE;
		}
 
		switch( iRand )
		{
			case 0: snprintf( Message, MAX_TEXT_LENGTH, "%s tried to put the pin back in!!!", NameV );
			case 1: snprintf( Message, MAX_TEXT_LENGTH, "%s:^n Damn! I hate it when that happens!", NameV );
			case 2: snprintf( Message, MAX_TEXT_LENGTH, "%s:^n Well I guess it is back to nade-throwing school for me. . .", NameV );
			case 3: snprintf( Message, MAX_TEXT_LENGTH, "%s:^n Holy wacky nade physics, Batman!", NameV );
			case 4:	snprintf( Message, MAX_TEXT_LENGTH, "A lesson in how not to use a nade!^n Demonstrated by %s.", NameV );
			default: snprintf( Message, MAX_TEXT_LENGTH, "%s tried to put the pin back in!!!", NameV );
		}
		printMessage( Message );
 
	}
	return PLUGIN_HANDLED;
}
 
printMessage( Message[ ] )
{
	new iRandRed = random( 3 );
	new iRandGreen = random( 3 );
	new iRandBlue = random( 3 );
 
	new iRandSayType = random( 2 );
 
	switch( iRandRed )
	{
		case 0:	iRandRed = 10;
		case 1:	iRandRed = 150;
		case 2:	iRandRed = 255;
	}
 
	switch( iRandGreen )
	{
		case 0:	iRandGreen = 10;
		case 1:	iRandGreen = 150;
		case 2:	iRandGreen = 255;
	}
 
	switch( iRandBlue )
	{
		case 0:	iRandBlue = 10;
		case 1:	iRandBlue = 150;
		case 2:	iRandBlue = 255;
	}
 
	if( iRandSayType )
		centersay( Message, 12, iRandRed, iRandGreen, iRandBlue );
	else typesay( Message, 6, iRandRed, iRandGreen, iRandBlue );
 
	return 1;
}
 
public plugin_init() {
	plugin_registerinfo("Fun Kill Announcer","Throws a random center/typesay when someone gets killed.",STRING_VERSION);
	plugin_registercmd("logd_funkill", "logd_funkill", ACCESS_CONSOLE, "");
	plugin_registerinfo("Suicide Announcer","Throws a random center/typesay when someone commits suicide.",STRING_VERSION);
	plugin_registercmd("logd_suicide", "logd_suicide", ACCESS_CONSOLE, "");
 
	exec( "logd_reg 57 admin_command logd_funkill" );
	exec( "logd_reg 53 admin_command logd_suicide" );
	return PLUGIN_CONTINUE;
}