
/* AMX Mod script. 
* 
* (c) Copyright 2002-2003, OLO 
* This file is provided as is (no warranties). 
* 
*/ 

#include <amxmod> 

new gMenu
new gKillers[33] 
new gPunishMe[33] 

public menu_option1(id,keys){ 
	if (gPunishMe[gKillers[id]]) {
		gPunishMe[gKillers[id]] = 0 
		new name1[32], name2[32] 
		get_user_name(id,name1,31)
		get_user_name(gKillers[id],name2,31)
		client_print(0,print_chat,"* %s punished by %s",name2,name1) 
		user_kill(gKillers[id]) 
	}
	else 
		client_print(id,print_chat,"* Too late for any action") 
	return PLUGIN_HANDLED 
} 

public menu_option2(id,keys){ 
	if (gPunishMe[gKillers[id]]) {
		gPunishMe[gKillers[id]] = 0   
		new name1[32], name2[32]
		get_user_name(id,name1,31)
		get_user_name(gKillers[id],name2,31)
		user_slap(gKillers[id],50) 
		client_print(0,print_chat,"* %s slaped %s with 50hp for teamkilling",name1,name2) 
	} 
	else 
		client_print(id,print_chat,"* Too late for any action") 
	return PLUGIN_HANDLED 
} 

public menu_option3(id,keys){ 
	if (gPunishMe[gKillers[id]]) { 
		gPunishMe[gKillers[id]]=0  
		new name1[32], name2[32]
		get_user_name(id,name1,31) 
		get_user_name(gKillers[id],name2,31)
		client_print(0,print_chat,"* %s forgave %s",name1,name2) 
	} 
	else 
		client_print(id,print_chat,"* Too late for any action") 
	return PLUGIN_HANDLED 
} 

public menu_option4(id,keys){ 
	if (gPunishMe[gKillers[id]]){ 
		new name[32] 
		get_user_name(gKillers[id],name,31)
		client_print(0,print_chat,"* %s will be punished on nextround",name) 
	} 
	else 
		client_print(id,print_chat,"* Too late for any action") 
	return PLUGIN_HANDLED 
} 

public show_tkmenu(param[]){
	new szmenu[256], name[32]
	get_user_name(param[1],name,31) 
	format(szmenu,255,"\yTK Revenge on %s^n^n\w1. Kill now!^n2. Slap with 50hp^n3. Forgive TK^n^n4. Punish on nextround",name) 
	show_menu(param[0],((1<<0)|(1<<1)|(1<<2)|(1<<3)),szmenu) 
} 

public death_msg(id){ 
	new killer = read_data(1) 
	new victim = read_data(2) 
	if ( killer && (killer!=victim) && (get_user_team(killer)==get_user_team(victim)) ) { 
		gKillers[victim] = killer  
		gPunishMe[killer] = 1
		new param[2]
		param[0] = victim
		param[1] = killer
		set_task(0.25,"show_tkmenu",0,param,2)
	}
	return PLUGIN_CONTINUE 
} 

public delayed_kill(param[]){ 
	client_print(param[0],print_chat,"* You have been punished for killing the teammate(s)") 
	user_kill(param[0])
	return PLUGIN_CONTINUE
} 

public reset_hud(id){ 
	if (gPunishMe[id]){ 
		gPunishMe[id] = 0 
		new param[2] 
		param[0] = id 
		set_task(0.25,"delayed_kill",0,param,2) 
	}
	return PLUGIN_CONTINUE 
} 

public client_connect(id){ 
	gPunishMe[id] = 0 
	return PLUGIN_CONTINUE 
} 

public client_disconnect(id){ 
	gPunishMe[id] = 0 
	return PLUGIN_CONTINUE 
} 

public reset_punishment(){
	new imax = get_maxplayers()
	for(new a = 1; a<=imax; ++a)  
		gPunishMe[a] = 0
	return PLUGIN_CONTINUE       
}

public plugin_init(){ 
	register_plugin("TK Revenge","0.9","default") 
	gMenu = register_menuid("\yTK Revenge on") 
	register_menucmd(gMenu,(1<<0),"menu_option1") 
	register_menucmd(gMenu,(1<<1),"menu_option2") 
	register_menucmd(gMenu,(1<<2),"menu_option3")    
	register_menucmd(gMenu,(1<<3),"menu_option4") 
	register_event("TextMsg","reset_punishment","a","2&#Game_C","2&#Game_w") 
	register_event("ResetHUD","reset_hud","b") 
	register_event("DeathMsg","death_msg","a") 
	set_cvar_float("mp_tkpunish",0.0) 
	return PLUGIN_CONTINUE 
}

