// es_tkclown
// Author: Lumpi@Work
// Version: 1.4 | Build Date: 12/16/08
// Description: Teamkillers will get a clown (or another) model for one round (for EventScripts 1.5)

/////////////////////////
// SCRIPT CONFIGURATION
/////////////////////////

block tkclown_conf
{
	// Set the model which the teamkiller will get, don't forget to also customize the block downloadables if you use another model!
	es_xset tkclown_model_t "player/tkclown/clown_leet/t_leet"
	es_xset tkclown_model_ct "player/tkclown/clown_gsg9/ct_gsg9"

	// Add round 1 = the teamkiller will get the clown model again next round / 0 = only in current round
	es_xset tkclown_addround 1

	// Customize the messages

	// The message which will be shown to the teamkiller
	es_xset tkclown_message1 "You killed a teammate! Now you become a clown!"
	// The message which will be shown to the victim
	es_set tkclown_message2 "You got teamkilled by server_var(tkname), now he becomes a clown!"
	// The message which will be shown to all players
	es_xset tkclown_message3 "Woohooo, i'm a clown!"
}

/////////////////////////
// END OF CONFIG
/////////////////////////

block load
{
	es_xset tkclown_ver 1.4
	es_makepublic tkclown_ver
	es_xset tkclown_status 0
	es_xset tkid 0
	es_xset tkname 0
	es_xset tkteam 0

	es_keygroupcreate tkclown_active
	es_keycreate tkclown_active teamkiller

	es_xdoblock tkclown/tkclown_conf

	es_xmsg #multi #green[TKClown]#default: #lightgreenLoaded - Made by [BuH]Lump1

	ifx true(eventscripts_currentmap) do
	{
		es_xdoblock tkclown/downloadables
	}
}

block unload
{
	es_xmsg #multi #green[TKClown]#default: #lightgreenUnloaded
}

block downloadables
{
	// Leet Clown Model Files (T)
	downloadable materials/models/player/tkclown/clown_leet/t_leet.vtf
	downloadable materials/models/player/tkclown/clown_leet/t_leet.vmt
	downloadable materials/models/player/tkclown/clown_leet/t_leet_glass.vtf
	downloadable materials/models/player/tkclown/clown_leet/t_leet_glass.vmt
	downloadable models/player/tkclown/clown_leet/t_leet.dx80.vtx
	downloadable models/player/tkclown/clown_leet/t_leet.dx90.vtx
	downloadable models/player/tkclown/clown_leet/t_leet.mdl
	downloadable models/player/tkclown/clown_leet/t_leet.phy
	downloadable models/player/tkclown/clown_leet/t_leet.sw.vtx
	downloadable models/player/tkclown/clown_leet/t_leet.vvd
	downloadable models/player/tkclown/clown_leet/t_leet.xbox.vtx

	// GSG9 Clown Model Files (CT)
	downloadable materials/models/player/tkclown/clown_gsg9/ct_gsg9.vtf
	downloadable materials/models/player/tkclown/clown_gsg9/ct_gsg9.vmt
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.dx80.vtx
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.dx90.vtx
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.mdl
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.phy
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.sw.vtx
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.vvd
	downloadable models/player/tkclown/clown_gsg9/ct_gsg9.xbox.vtx
}

block setskin
{
	es_keygetvalue tkid tkclown_active teamkiller tkpid
	es getplayerinfo tkteam server_var(tkid) teamid
	if (server_var(tkteam) equalto 2) do
	{
		es playerset model server_var(tkid) server_var(tkclown_model_t)
	}
	else do
	{
		es playerset model server_var(tkid) server_var(tkclown_model_ct)
	}
}

event es_map_start
{
	es_xdoblock tkclown/downloadables

	es_xset index 0
	es_precachemodel index "models/player/tkclown/clown_leet/t_leet.mdl"
	es_precachemodel index "models/player/tkclown/clown_gsg9/ct_gsg9.mdl"
}

event player_death
{ 
	if (event_var(es_attackerteam) equalto event_var(es_userteam)) do
	{
		if (event_var(attacker) notequalto event_var(userid)) do
		{
			es_keysetvalue tkclown_active teamkiller tkpid event_var(attacker)
			es_keysetvalue tkclown_active teamkiller tkpname event_var(es_attackername)
			es_keygetvalue tkname tkclown_active teamkiller tkpname

			es_tell event_var(userid) #multi #green server_var(tkclown_message2)
			es_tell event_var(attacker) #multi #green server_var(tkclown_message1)

			es_xdoblock tkclown/setskin
			es_sexec event_var(attacker) say server_var(tkclown_message3)
			es_xset tkclown_status 1
		}
	}
}

event round_start
{
	if (server_var(tkclown_status) equalto 1) do
	{
		if (server_var(tkclown_addround) equalto 1) do
		{
			es_xdoblock tkclown/setskin
			es_keygetvalue tkid tkclown_active teamkiller tkpid
			es_sexec server_var(tkid) say server_var(tkclown_message3)
			es_xset tkclown_status 0
		}
	}
}
