/*
* hp_award.sma
* 
* give killer +hp
*
* thx to jordy, v3x:
* http://forums.alliedmods.net/showthread.php?t=28153
*
*/

#include <amxmodx> 
#include <fun> 

// Plugin Info
new const PLUGIN[]  = "HP Award For Kill"
new const VERSION[] = "0.8c"		// released 25.01.2008
new const AUTHOR[]  = "Argus"

new award_hp, award_hp2, hp_MsgSync

public plugin_init() 
{
   register_plugin(PLUGIN, VERSION, AUTHOR)   
   register_event("DeathMsg" , "event_DeathMsg" , "a" ,  "1>0" , "2>0"); 
   register_cvar("hp_award","1")   
   register_cvar("hp_award_hp","60")	// head kill
   register_cvar("hp_award_hp2","15")	// body kill
   register_cvar("hp_award_show","1")   
   hp_MsgSync = CreateHudSyncObj()
}
 
public event_DeathMsg() 
{

	if(!get_cvar_num("hp_award"))
		return PLUGIN_HANDLED   
		
	new id = read_data(1)
	new bool:killhead = bool:read_data(3)
	new player_hp = get_user_health(id)
	
	award_hp = get_cvar_num("hp_award_hp")
	award_hp2 = get_cvar_num("hp_award_hp2")		
	
	if((killhead) && (award_hp>0) && (is_user_alive(id)))	// head kill
	{
		if((player_hp + award_hp) > 100)
			set_user_health(id , 100)
		else 
			set_user_health(id , player_hp+award_hp)

		if(get_cvar_num("hp_award_show"))
		{
			set_hudmessage(200, 200, 50, -1.0, 0.36, 2, 0.2, 0.2, 0.025, 0.02, -1)
			ShowSyncHudMsg(id, hp_MsgSync, "+%i^n", award_hp)
		}
	}

	if((!killhead) && (award_hp2>0) && (is_user_alive(id)))// body kill
	{
		if((player_hp + award_hp2) > 100)
			set_user_health(id , 100)
		else 
			set_user_health(id , player_hp + award_hp2)

		if(get_cvar_num("hp_award_show"))
		{
			set_hudmessage(50, 200, 50, -1.0, 0.36, 2, 0.2, 0.2, 0.02, 0.02, -1)
			ShowSyncHudMsg(id, hp_MsgSync, "+%i^n", award_hp2)
		}
	}
	
	return PLUGIN_CONTINUE	
}
