public item_gigai(id)
{
	if((find_ent_by_owner(-1,"npc_gigai",id,0)) || (!is_user_alive(id))) return PLUGIN_CONTINUE;
	
	static Float:origin[3];
	
	entity_get_vector(id,EV_VEC_origin,origin);
	
	new ent = create_entity("info_target");
	entity_set_string(ent,EV_SZ_classname,"npc_gigai");
	entity_set_edict(ent,EV_ENT_owner,id);

	entity_set_origin(ent,origin);
	
	entity_set_float(ent,EV_FL_takedamage,DAMAGE_AIM);
	entity_set_float(ent,EV_FL_health,100.0);
	
	if(get_user_team(id) == TEAM_CT)
	{
		entity_set_model(ent,"models/player/gign/gign.mdl");
	}
	else
	{
		entity_set_model(ent,"models/player/leet/leet.mdl");
	}
	
	entity_set_byte(ent,EV_BYTE_controller1,125);
	entity_set_byte(ent,EV_BYTE_controller2,125);
	entity_set_byte(ent,EV_BYTE_controller3,125);
	entity_set_byte(ent,EV_BYTE_controller4,125);
	
	static Float:max[3],Float:min[3];
	
	max[0] = 16.0;
	max[1] = 16.0;
	max[2] = 36.0;
	
	min[0] = -16.0;
	min[1] = -16.0;
	min[2] = -36.0;
	
	entity_set_size(ent,min,max);
	entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER);
	
	entity_set_float(ent,EV_FL_animtime,2.0);
	entity_set_float(ent,EV_FL_framerate,1.0);
	
	entity_set_int(ent,EV_INT_sequence,1);
	
	//---------------------------------------------------------------------
	
	new ent_weapon = create_entity("info_target");

	entity_set_string(ent_weapon,EV_SZ_classname,"npc_gigai_weapon");
	
	entity_set_int(ent_weapon,EV_INT_movetype,MOVETYPE_FOLLOW);
	entity_set_int(ent_weapon,EV_INT_solid,SOLID_NOT);
	
	entity_set_edict(ent_weapon,EV_ENT_aiment,ent);
	entity_set_edict(ent_weapon,EV_ENT_owner,ent);
	
	entity_set_model(ent_weapon,"models/p_deagle.mdl");
	
	//---------------------------------------------------------------------
	
	drop_to_floor(ent);
	g_player_item_in_use[id]=true;
	
	return PLUGIN_CONTINUE;
}

public item_gigai_touch(touched,toucher)
{
	if(entity_get_edict(touched,EV_ENT_owner) != toucher)
	{
		print_hud_status(toucher,"%L",toucher,"L_STATUS_NOT_YOURS");
		return PLUGIN_CONTINUE;
	}
	
	
	if(g_player_use[toucher])
	{
		static ent_weapon;
		ent_weapon = find_ent_by_owner(-1,"npc_gigai_weapon",touched,0);
		
		if(is_valid_ent(ent_weapon))
		{
			remove_entity(ent_weapon);
		}
		remove_entity(touched);
		g_player_item_in_use[toucher]=false;
	}
	else
	{
		print_hud_status(toucher,"%L",toucher,"L_STATUS_RESTORE");
	}
	
	return PLUGIN_CONTINUE;
}

public item_gigai_remove(id)
{
	static ent,ent_weapon;
	ent = find_ent_by_owner(-1,"npc_gigai",id,0);

	if(is_valid_ent(ent))
	{
		ent_weapon = find_ent_by_owner(-1,"npc_gigai_weapon",ent,0);
		if(is_valid_ent(ent_weapon))
		{
			remove_entity(ent_weapon);
		}
		remove_entity(ent);
	}
}
