File size: 2.19Kb
<?
require_once'../core/system.php';
echo only_reg();
echo ban();
echo blok();
$header='Завершение охоты';
require_once'../core/head.php';
$ruq = mysql_query("SELECT * from `hunting` where `usr` = '$user[id]'");
$hnt = mysql_fetch_array($ruq);
$avto= mysql_num_rows($ruq);
if($avto==0){
header("Location: /hunting/");
$_SESSION['err'] = 'Ошибка!';
exit();
}
if($hnt['status']==2){
$_SESSION['err'] = "Ошибка";
header('Location: /hunting/');
exit();
}
if($hnt['fight']==0){
$kolvo=rand(0,$hnt['level'])/2;
$kolvo2=floor((rand(1,$hnt['level'])*$exp)/200);
if($setgame['exp']==1)$kolvo2=$kolvo2*2;
$kolvoo=$kolvo*100;
if($kolvoo==50){$kolvo=50;}
if($kolvo>0){mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'Охота', `time` = '".$tm."', `kol`='".$kolvoo."', `kto`='+'");}
mysql_query("UPDATE `user` SET `gold` = `gold`+'$kolvoo' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `user` SET `exp` = `exp`+'$kolvo2' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `hunting` SET `status` = '2', `gold`=`gold`+'$kolvoo', `exp`=`exp`+'$kolvo2' WHERE `usr` = '$user[id]'");
if($kolvoo>=100){$gold='gold';}
if($kolvoo<100){$gold='silver';}
$_SESSION['light']="<font color='orange'> Охота успешно завершена!</font></br>
<span class='blue'>Получено: <img src='/images/icon/exp.png' alt=''/>$kolvo2 <img src='/images/icon/$gold.png' alt=''/>$kolvo </span> ";
header("Location: /hunting/");
exit;
} else {
$mob=rand(1,2);
if($mob==1){$mob='Бешеный Медведь';}
if($mob==2){$mob='Большой Тигр';}
$t=time()+3600;
$nextudar=rand(3,12);
$nextud=time()+$nextudar;
$tata=floor($user['param']/5);
$tatahp=$tata*10;
$kolhp=$user['max_health']/2;
if($user['health']==0){mysql_query("UPDATE `user` SET `health` = '$kolhp' WHERE `id` = '$user[id]'");}
mysql_query("DELETE FROM `battle` WHERE `usr`='$user[nick]'");
mysql_query("INSERT INTO `battle` SET `usr`='$user[nick]', `name`='$mob', `status`='', `hpmax`='$tatahp', `hp`='$tatahp', `sila`='$tata', `prot`='$tata', `time`='$t', `nextud`='$nextud'");
$_SESSION['light']='На вас напал '.$mob.'!';
header('Location: /hunting/fight');
exit;
}
require_once'../core/foot.php';
?>