 /*
amx_autoshoot

By: Petey B

Credit: Xavior

ONLY USE FOR FUN NOT DURING CLAN MATCHES OR ANYTHING OF THAT NATURE

Commands:
amx_autoshoot <player>
amx_unautoshoot <player>
*/
#include <amxmod>
#include <amxmisc>
#include <fun>
#include <zombieplague>

new g_autoshoot
new auto[33]


public plugin_init (){
	register_plugin("Auto Shoot","0.1","Petey B")
	register_cvar("sv_head", "0") 
	register_event("HLTV", 		"Event_NewRound", 	"a", 	"1=0", "2=0")
	g_autoshoot = zp_register_extra_item("Auto Shoot", 10, ZP_TEAM_HUMAN)
 }

public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_autoshoot)
		client_print(player, print_chat, "[ZP] You have Auto Shoot!")

		new param[2] 
		param[0] = player
		auto[player] = 1
	set_task (0.1,"autoshoot",0,param,1,"b")

}
public autoshoot(param[]) { 
	new id = param[0] 
	//if(!is_user_alive(id)) 
	if(auto[id] ==1)
	{
	new target,body
	get_user_aiming(id,target,body)
	//client_print(id,print_chat,"%d %d %s",hzone[target], body, body)
	if(get_user_team(id) != get_user_team(target)){
		if (get_user_team(target)==1 || get_user_team(target)==2)
		{
			//client_print(id,print_chat,"%d",body)
			if(get_cvar_num("sv_head")==1 && body == 1&& is_user_alive(id)==1)
				client_cmd(id,"+attack;wait;-attack")
			if(get_cvar_num("sv_head")==0 && is_user_alive(id)==1)
				client_cmd(id,"+attack;wait;-attack")
		}
	}
	}	
	return PLUGIN_CONTINUE
}

public Event_NewRound() 
{
		new Players[32], iNum = 0
		get_players(Players, iNum)
		for(new i = 0; i < iNum; i++) 
		{
			new id = Players[i]

			auto[id] = 0
	
		}
	
	
}
