
/* AMXMOD script.
*
* (c) Copyright 2000-2002, f117bomb
* This file is provided as is (no warranties).
*
*/

#include <amxmod>

/*
* amx_heal < part of nick > or < @ team > or < # index > < life to give >
*
*/

public heal_player(admin_index,victim_index,health_give)
{
	new name[32]	
	get_user_name(victim_index,name,32)
	if (get_user_flags(victim_index)&ADMIN_IMMUNITY)
	{
		client_print(admin_index,print_console,"[AMX] Client ^"%s^" has immunity",name)
		return PLUGIN_HANDLED
	}
	new user_health = get_user_health(victim_index)
	set_user_health(victim_index, health_give + user_health)
	client_print(admin_index,print_console,"[AMX] Client ^"%s^" has been healed",name)
	return PLUGIN_CONTINUE
}

public admin_heal(id)
{
	if (!(get_user_flags(id)&ADMIN_LEVEL_A)){
		client_print(id,print_console,"[AMX] You have no access to that command")
		return PLUGIN_HANDLED
	}
	new argc = read_argc()
	if (argc < 3) { 
		client_print(id,print_console,"[AMX] Usage: amx_heal < part of nick > or < @ team > or < # index > < life to give >")
		return PLUGIN_HANDLED
	}
	new arg1[32]
	new arg2[32]
	new arg3[32]
	read_argv(1,arg1,32)
	read_argv(2,arg2,32)
	read_argv(3,arg3,32)
	//Team
	if (equal(arg1,"@")){
		new players[32], inum
		get_players(players,inum,"e",arg2)
		for(new i = 0 ;i < inum ;++i)
			heal_player(id,players[i],str_to_num(arg3))
		if (inum)
			client_print(id,print_console,"[AMX] * All non-immune clients from ^"%s^" team affected *",arg2)
		else
			client_print(id,print_console,"[AMX] No clients in such team")
	}
	//Index
	else if (equal(arg1,"#")) {
		if (is_user_connected(str_to_num(arg2)))
			heal_player(id,str_to_num(arg2),str_to_num(arg3))
		else 
			client_print(id,print_console,"[AMX] Client not found")
	}
	//Part of Name
	else 
	{
		new player = find_player("lb",arg1)
		if (player)
			heal_player(id,player,str_to_num(arg2))
		else 
			client_print(id,print_console,"[AMX] Client with that part of nick not found")
	}
	return PLUGIN_HANDLED
}

public plugin_init()
{
	register_plugin("Admin Heal","0.7","f117bomb")
	register_clcmd("amx_heal","admin_heal",ADMIN_LEVEL_A,"amx_heal < part of nick > or < @ team > or < # index > < life to give >")
	return PLUGIN_CONTINUE
}

