Файл: taverna.php
Строк: 101
<?
define('PROTECTOR', 1);
$headmod = 'taverna';//фикс. места
$textl='Таверна';
include('files/path.php');
include('files/db.php');
include('files/auth.php');
include('files/func.php');
going();
zasad();
ryd();
place_okr();
place_zamok();
place_tower();
include('files/core.php');
include('files/head.php');
include('files/zag.php');
switch($_GET[mod]){
default:
$br = mysql_query("SELECT * FROM npc WHERE city = '$udata[city]' ORDER BY id");
////////////////////////////
$avto=mysql_num_rows($br);
if($avto>=1){
$req = mysql_query("SELECT * FROM taverna WHERE city = '$udata[city]'");
$n = mysql_fetch_array($req);
$c=explode(",",$n[npc]);
$co=count($c)-1;
$np=rand(0,$co);
$npc_now=$c[$np];
$req = mysql_query("SELECT * FROM npc WHERE id = '$npc_now'");
$nid = mysql_fetch_array($req);
$ue=FALSE;
if(!empty($nid[quest])){
$v=explode(",",$nid[quest]);
$vk=count($v);$i=0;$b=1;
while($b<=$vk){
$req = mysql_query("SELECT * FROM `userquests` WHERE `quest` = '$v[$i]' and `usr`='$log'");
$avto=mysql_num_rows($req);
if($avto==1){$j = mysql_fetch_array($req);}
if($avto==0 or $j[status]==start){
$nid[quest]=$v[$i];
$ue=TRUE;
break;}$i++;$b++;}}
if($ue==FALSE){$nid[quest]=0;}
$req = mysql_query("SELECT * FROM `npc_speack` WHERE `npc` = '$npc_now' and `dialog`='begin' and `quest`='$nid[quest]'");
$dialog = mysql_fetch_array($req);
$dialog=explode("|",$dialog[text]);
$dialog[0]= str_replace('<name>',"$log", "$dialog[0]");
echo"<b>$nid[name]:</b><br/>";
echo'<div class="event">';
echo"<img src="pic/npc/$nid[img]" alt="$nid[name]" style="float:left;margin-right:8px;"/>$dialog[0]<br/>";
echo"<a href="npc.php?id=$npc_now">Поговорить</a></div>";
echo"<b>Персонажи:</b><br/>";
While($npc = mysql_fetch_array($br)){
echo"<img src='pic/main/star.png' alt='*'/> <a href="npc.php?id=$npc[id]">$npc[name]</a><br/>";
}}else{
echo"<b>В таверне нет персонажей!</b><br/>";}
echo"<div class="event"><b>Активные квесты:</b><br/>";
$req = mysql_query("SELECT * FROM `userquests` WHERE `usr` = '$log' and `status`='start'");
if(empty($_GET[id])){
While($q = mysql_fetch_array($req))
{
$reqo = mysql_query("SELECT * FROM `quests` WHERE `id` = '$q[quest]'");
$quest = mysql_fetch_array($reqo);
echo"<a href="taverna.php?mod=quests&act=start&id=$q[id]"><b>$quest[name]</b></a><br/>";}}
echo"<div class="event"><b>Завершенные:</b><br/>";
$req = mysql_query("SELECT * FROM `userquests` WHERE `usr` = '$log' and `status`='complete'");
if(empty($_GET[id])){
While($q = mysql_fetch_array($req))
{
$reqo = mysql_query("SELECT * FROM `quests` WHERE `id` = '$q[quest]'");
$quest = mysql_fetch_array($reqo);
echo"<a href="taverna.php?mod=quests&act=complete&id=$q[id]"><b>$quest[name]</b></a><br/>";
}}echo"</div></div>";
case 'quests':
if($_GET[act]==start){
$req = mysql_query("SELECT * FROM `userquests` WHERE `usr` = '$log' and `status`='start'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'Нет квестов!';
include"files/down.php";exit;}
if(empty($_GET[id])){
While($q = mysql_fetch_array($req)){
$reqo = mysql_query("SELECT * FROM `quests` WHERE `id` = '$q[quest]'");
$quest = mysql_fetch_array($reqo);
echo"<a href="taverna.php?mod=quests&act=start&id=$q[id]"><b>Квест $quest[name]</b></a><br/>";}}else{
$req = mysql_query("SELECT * FROM `userquests` WHERE `usr` = '$log' and `status`='start' and `id`='$_GET[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'Нет такого квеста!';
include"files/down.php";exit;
}
$q = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `quests` WHERE `id` = '$q[quest]'");
$quest = mysql_fetch_array($req);
echo"<b>$quest[name]</b><br/>";
echo"<b>Задание:</b>$quest[mission]<br/>";
echo"Статус: [<b>Активен</b>]<br/>";
}
}elseif($_GET[act]==complete){
$req = mysql_query("SELECT * FROM `userquests` WHERE `usr` = '$log' and `status`='complete'");
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'Нет квестов!';
include"files/down.php";exit;}
if(empty($_GET[id])){
While($q = mysql_fetch_array($req)){
$reqo = mysql_query("SELECT * FROM `quests` WHERE `id` = '$q[quest]'");
$quest = mysql_fetch_array($reqo);
echo"<a href="index.php?mod=quests&act=complete&id=$q[id]"><b>Квест $quest[name]</b></a><br/>";}}else{
$req = mysql_query("SELECT * FROM `userquests` WHERE `usr` = '$log' and `status`='complete' and `id`='$_GET[id]'");
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'Нет такого квеста!';
include"files/down.php";exit;}
$q = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `quests` WHERE `id` = '$q[quest]'");
$quest = mysql_fetch_array($req);
echo"<b>$quest[name]</b><br/>";
echo"<b>Задание:</b>$quest[mission]<br/>";
echo"Статус: [<b>Завершён</b>]<br/>";}}else{
echo"<a href="taverna.php?mod=quests&act=start">Активные</a><br/>";
echo"<a href="taverna.php?mod=quests&act=complete">Завершёные</a><br/>";}
echo"<a href="taverna.php?">Назад</a>";
break;
break;
}
include('files/down.php');
?>