<?
$use = $_GET['use'];
$uset = $_GET['uset'];
$t=time();
$prDEAD=mysql_query("SELECT * FROM users WHERE statys=\"1\" AND NICK=\"$_SESSION[s]\"");
$prHP=mysql_query("SELECT * FROM users WHERE NICK=\"$_SESSION[s]\"");
$useZ=mysql_query("SELECT * FROM inv WHERE ID_IL=\"$use\" AND ID_USERS=\"$_SESSION[s]\"");
$useZ2=mysql_fetch_assoc($useZ);
$prHP2=mysql_fetch_assoc($prHP);
$zelTIMER=mysql_query("SELECT * FROM timerzeliya WHERE TZ_CLASS=\"zeliyaZ\" AND T_NICKx=\"$_SESSION[s]\"");
$zelTIMER2=mysql_fetch_assoc($zelTIMER);
$zelTIMER3=mysql_query("SELECT * FROM timerzeliya WHERE TZ_CLASS=\"zeliyaM\" AND T_NICKx=\"$_SESSION[s]\"");
$zelTIMER4=mysql_fetch_assoc($zelTIMER3);
if(mysql_num_rows($prDEAD)>0 AND isset($use)){
echo"<div class=\"main_title\"><font color=\"red\"><center><img src=\"img/bad.png\" width=\"16\" height=\"16\"> вы призрак и не можете использовать зелья</font></center></div>";}
if(mysql_num_rows($useZ)<1 AND isset($use)){
echo"<div class=\"main_title\"><font color=\"red\"><center><img src=\"img/bad.png\" width=\"16\" height=\"16\"> у вас нет такого предмета</font></center></div>";}
if($prHP2[MINhp]==$prHP2[MAXhp] AND isset($use) AND $useZ2[IL_CLASS]=='zeliyaZ'){
echo"<div class=\"main_title\"><font color=\"red\"><center><img src=\"img/bad.png\" width=\"16\" height=\"16\"> вы полностью здоровы и не нуждаетесь в излечении</font></center></div>";}
if($prHP2[MINmp]==$prHP2[MAXmp] AND isset($use) AND $useZ2[IL_CLASS]=='zeliyaM'){
echo"<div class=\"main_title\"><font color=\"red\"><center><img src=\"img/bad.png\" width=\"16\" height=\"16\"> ваша магическая энергия полна,вам нет необходимости пить зелье</font></center></div>";}
if(mysql_num_rows($useZ)>0){
if($zelTIMER2[TZ_TIME]>$t AND $useZ2[IL_CLASS]=='zeliyaZ'){echo"вам нужно отдохнуть еще:".($zelTIMER2[TZ_TIME]-$t);}
if($zelTIMER4[TZ_TIME]>$t AND $useZ2[IL_CLASS]=='zeliyaM'){echo"вам нужно отдохнуть еще:".($zelTIMER4[TZ_TIME]-$t);}
if($zelTIMER2[TZ_TIME]<$t){
//здесь не последнее зелье
if(mysql_num_rows($prDEAD)<1 AND isset($use) AND $prHP2[MINhp]!=$prHP2[MAXhp]){
if($useZ2[IL_COUNT]-1>0){
if($useZ2[IL_CLASS]=='zeliyaZ'){echo'<center><b>вы использовали '.$useZ2[IL_NAME].' здоровье + '.$useZ2[IL_MIN_DMG].'</b></center>';}
//добавляем здоровье от зелья
$hpp=$prHP2[MINhp]+$useZ2[IL_MIN_DMG];
if($prHP2[MINhp]+$useZ2[IL_MIN_DMG]>$prHP2[MAXhp]){$updaHP=mysql_query("UPDATE users SET MINhp=MAXhp WHERE NICK=\"$_SESSION[s]\"");}
if($prHP2[MINhp]+$useZ2[IL_MIN_DMG]<=$prHP2[MAXhp]){$updaHP=mysql_query("UPDATE users SET MINhp=\"$hpp\" WHERE NICK=\"$_SESSION[s]\"");}
$zelZm=$useZ2[IL_COUNT]-1;
$zelUPd=mysql_query("UPDATE inv SET IL_COUNT=\"$zelZm\" WHERE ID_IL=\"$use\" AND ID_USERS=\"$_SESSION[s]\"");
}

//здесь последнее зелье
if($useZ2[IL_COUNT]-1==0){
if($useZ2[IL_CLASS]=='zeliyaZ'){echo'<center><b>вы использовали '.$useZ2[IL_NAME].' здоровье + '.$useZ2[IL_MIN_DMG].'</b></center>';}
$hpp=$prHP2[MINmp]+$useZ2[IL_MIN_DMG];
if($prHP2[MINhp]+$useZ2[IL_MIN_DMG]>$prHP2[MAXhp]){$updaHP=mysql_query("UPDATE users SET MINhp=MAXhp WHERE NICK=\"$_SESSION[s]\"");}
if($prHP2[MINhp]+$useZ2[IL_MIN_DMG]<=$prHP2[MAXhp]){$updaHP=mysql_query("UPDATE users SET MINhp=\"$hpp\" WHERE NICK=\"$_SESSION[s]\"");}
$delZElz=mysql_query("DELETE FROM inv WHERE ID_IL=\"$use\" AND ID_USERS=\"$_SESSION[s]\"");
}
}
}
if($zelTIMER4[TZ_TIME]<$t){
//здесь не последнее зелье
if(mysql_num_rows($prDEAD)<1 AND isset($use) AND $prHP2[MINmp]!=$prHP2[MAXmp]){
if($useZ2[IL_COUNT]-1>0){
//if($useZ2[IL_CLASS]=='zeliyaM'){echo'<center><b>вы использовали '.$useZ2[IL_NAME].' здоровье + '.$useZ2[IL_MIN_DMG].'</b></center>';}
if($useZ2[IL_CLASS]=='zeliyaM'){echo'<center><b>вы использовали '.$useZ2[IL_NAME].' мана + '.$useZ2[IL_MIN_DMG].'</b></center>';}
$hpp=$prHP2[MINmp]+$useZ2[IL_MIN_DMG];
if($prHP2[MINmp]+$useZ2[IL_MIN_DMG]>$prHP2[MAXmp]){$updaHP=mysql_query("UPDATE users SET MINmp=MAXmp WHERE NICK=\"$_SESSION[s]\"");}
if($prHP2[MINmp]+$useZ2[IL_MIN_DMG]<=$prHP2[MAXmp]){$updaHP=mysql_query("UPDATE users SET MINmp=\"$hpp\" WHERE NICK=\"$_SESSION[s]\"");}
$zelZm=$useZ2[IL_COUNT]-1;
$zelUPd=mysql_query("UPDATE inv SET IL_COUNT=\"$zelZm\" WHERE ID_IL=\"$use\" AND ID_USERS=\"$_SESSION[s]\"");
}

//здесь последнее зелье
if($useZ2[IL_COUNT]-1==0){
//if($useZ2[IL_CLASS]=='zeliyaM'){echo'<center><b>вы использовали '.$useZ2[IL_NAME].' здоровье + '.$useZ2[IL_MIN_DMG].'</b></center>';}
if($useZ2[IL_CLASS]=='zeliyaM'){echo'<center><b>вы использовали '.$useZ2[IL_NAME].' мана + '.$useZ2[IL_MIN_DMG].'</b></center>';}
$hpp=$prHP2[MINmp]+$useZ2[IL_MIN_DMG];
if($prHP2[MINmp]+$useZ2[IL_MIN_DMG]>$prHP2[MAXmp]){$updaHP=mysql_query("UPDATE users SET MINmp=MAXmp WHERE NICK=\"$_SESSION[s]\"");}
if($prHP2[MINmp]+$useZ2[IL_MIN_DMG]<=$prHP2[MAXmp]){$updaHP=mysql_query("UPDATE users SET MINmp=\"$hpp\" WHERE NICK=\"$_SESSION[s]\"");}
$delZElz=mysql_query("DELETE FROM inv WHERE ID_IL=\"$use\" AND ID_USERS=\"$_SESSION[s]\"");
}
}
}
}
?>