<?
define('PROTECTOR', 1);

$headmod = 'taverna';//фикс. места

$textl='Таверна';
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
going();
zasad();
ryd();
place_okr();
place_zamok();
place_tower();
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
              echo'<div class="end" align="center"><img src="pic/tavern.jpg"/></div>';


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/>";
}
break;
}
include($path.'files/down.php');
?>