<?php
reg();
$skill_id = int($_GET['skill']);
$skill = mysql_fetch_assoc(mysql_query("SELECT * FROM `skils_user` WHERE `user_id`='".$user['id']."' AND `skil_id`='".$skill_id."' LIMIT 1"));
if(!isset($_GET['skill']) or  empty($_GET['skill']) or !$skill){
header('Location: index.php');
exit;
}
if($user['mana']< $skill['mana']){
echo '<div id="error">Недостаточно MP!</div>';

}else{

$skill_name = mysql_fetch_assoc(mysql_query("SELECT `skil` FROM `skils` WHERE `id`='".$skill_id."' LIMIT 1"));
$skills_ur = array(1,3,4,6,7,9,10,12,13,15);
$skills_hp = array(2,5);
$skills_str = array(8,11);
if(in_array($skill_id,$skills_ur)){
echo '<div id="error"><b>'.$skill_name['skil'].'</b> нанес <b>'.$skill['uron'].'</b> урона</div>';
$weapon+=$skill['uron'];
#mysql_query("UPDATE `monster` SET `health`=`health`-".$skill['uron']." WHERE `id`='".$id."'");

}elseif(in_array($skill_id,$skills_hp)){
echo '<div id="error"><b>'.$skill_name['skil'].'</b> регенерирует <b>'.$skill['hp'].'</b> HP</div>';
	if($skill['hp']+$user['health'] >=$user['max_health']){
	
	mysql_query("UPDATE `users` SET 
	`health`='".$user['max_health']."',
	`health_resp`=0
	WHERE `id`='".$user['id']."'");
	}else{
	mysql_query("UPDATE `users` SET `health`=`health`+".$skill['hp']." WHERE `id`='".$user['id']."'");
	}
}elseif(in_array($skill_id,$skills_str)){
echo '<div id="error"><b>'.$skill_name['skil'].'</b> дает вам <b>'.$skill['str'].'</b> силы на 2 минуты</div>';
	if($skill_id==11){
	mysql_query("UPDATE `users` SET `skill_bers`='".$skill['id']."',`skill_time`='".time()."' WHERE `id`='".$user['id']."'");
	}elseif($skill_id==8){
	mysql_query("UPDATE `users` SET `skill_snaip`='".$skill['id']."',`skill_time`='".time()."' WHERE `id`='".$user['id']."'");
	}
	}elseif($skill_id == 14){
	echo '<div id="error"><b>'.$skill_name['skil'].'</b> дает вам <b>'.$skill['def'].'</b> защиты на 2 минуты</div>';
	mysql_query("UPDATE `users` SET `skill_soprotiv`='".$skill['id']."',`skill_time`='".time()."' WHERE `id`='".$user['id']."'");
	}
mysql_query("UPDATE `users` SET `mana`=`mana`-".$skill['mana'].",`mana_resp`='".time()."' WHERE `id`='".$user['id']."'");
		}
/*if($skill['']*/


?>