/*
* Bud-froggy Productions® -- July 26nd, 2001
* knife Kill Announcer® reedited by mikey, to be a headshot kill * announcer, sorry bud, its still your code, i just tweaked it to work * for headshots in tfc ;o
* 
* Announces headshot fragging
*
* Place in logd_kill
*/
 
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_CONSOLE 131072
 
new STRING_VERSION[MAX_DATA_LENGTH] = "v1";
 
 
playFile( sFileName[ ] ) {
	new Name[ MAX_NAME_LENGTH ];
	new iPlayerCount = maxplayercount( );
 
	for( new i = 1; i <= iPlayerCount; i++ ) {
		if( playerinfo( i, Name, MAX_NAME_LENGTH ) ){
			playsound(Name, sFileName );
		}
	}
	return 1;
}
 
public logd_headshot(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, "headshot") == 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:		//we need braces inside the switch statements for some reason
			{		//if soneone figures out why, tell me please!!! :)		
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s killed %s^n with a headshot!!!", NameA, NameV );
				printMessage( Message );
			}
			case 1:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s, you were just ^nn00b-ized^nby %s.", NameV, NameA );
				printMessage( Message );
			}
			case 2:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s just put ^na bullet thru^n%s's head!!!", NameA , NameV );
				printMessage( Message );
			}
			case 3:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s oWneD^n%s with a headshot!!!", NameA, NameV );
				printMessage( Message );
			}
			case 4:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s got headshot ^nby %s", NameV, NameA );
				printMessage( Message );
			}
			case 5:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "Headshot Kill by ^n%s^nOoga Shaka!!!", NameA );
				printMessage( Message );
			}
			case 6:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s is now dead,^ncourtesy of %s.", NameV, NameA );
				printMessage( Message );
			}
			case 7:
			{
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s,^nthe other white meat.", NameV );
				printMessage( Message );
			}
			case 8:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "Headshot!!!^nnice shot %s", NameA );
				printMessage( Message );
			}
			default:
			{	
				playFile( "misc/headshot.wav" );
				snprintf( Message, MAX_TEXT_LENGTH, "%s just put a bullet thru^n%s's head!!!", NameA, 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("headshot Kill Announcer","Throws a random center/typesay when someone gets headshot.",STRING_VERSION);
  	plugin_registercmd("logd_headshot", "logd_headshot", ACCESS_CONSOLE, "");
 
	exec( "logd_reg 57 admin_command logd_headshot" );
	return PLUGIN_CONTINUE;
}