Вход Регистрация
Файл: www/location.php
Строк: 1452
<?php
include 'inc/mysql.php';

include 
'inc/check.php';

include 
'inc/functions.php';

top();

include 
'inc/account.php';
 
$titlestr='Локация';
include 
'inc/interface.php';
if(isset(
$_SESSION['auth']) && $_SESSION['auth']==1){
    
$location=mysql_fetch_array(mysql_query("SELECT * FROM `location` WHERE `y`='".$account['y']."' AND `x`='".$account['x']."'"));
    if(isset(
$_GET['npc']) && is_numeric($_GET['npc'])){
        
$npc=intval($_GET['npc']);
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `npc` WHERE `id`='".$npc."' AND `x`='".$location['x']."' AND `y`='".$location['y']."'"),0)){
            
$npc=mysql_fetch_array(mysql_query("SELECT * FROM `npc` WHERE `id`='".$npc."' AND `x`='".$location['x']."' AND `y`='".$location['y']."'"));
            echo 
'<div class="title">'.$npc['name'].'</div>';
            if (isset(
$_GET['shop'])){
                
                if (
$npc['items']){
                if (isset(
$_GET['buy'])){
                    
$_GET['buy']=intval($_GET['buy']);
                    
$drop=explode(',',$npc['items']);
                    
$true=false;
                        foreach(
$drop as $valueee){
                            
                            
$item=explode(':',$valueee);
                                if (
$item[0]==$_GET['buy']){
                                    
$true=$item;
                                }
                                
/*
                                $iteme=mysql_fetch_assoc(mysql_query("SELECT * FROM `items` WHERE 
                                `id`='".$item[0]."'"));
                                if (preg_replace("weapon_{.}"," ",$iteme['type'])){
                                
                                }
                                elseif(preg_replace("armor_{.}"," ",$iteme['type'])){
                                
                                }
                                elseif(preg_replace("eat_{.}"," ",$iteme['type'])){
                                
                                }*/
                                //unset($iteme);
                                //
                        
}
                        
$item $true;
                        
$iteme=mysql_fetch_assoc(mysql_query("SELECT * FROM `items` WHERE 
                                `id`='"
.$item[0]."'"));
                        if (
$true){
                            if (
$iteme['type']=='eat_eat' || $iteme['type']=='eat_bottle'){
                            if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `inventory` WHERE `ident_id`='".$iteme['id']."' AND `account`='".$account['id']."'"),0)){
                                
mysql_query("UPDATE `inventory` SET 
                                            `amount`=`amount` + '1' 
                                            WHERE
                                            `ident_id`='"
.$iteme['id']."'
                                            AND `account`='"
.$account['id']."'");
                                            
mysql_query("UPDATE `account` SET `gold`=`gold`-'".$item[1]."'");
                                            echo 
'<div class="help">Получен предмет: '.$iteme['name'].'</div>';
                                        
//echo '<div class="help">Получен предмет: '.$iteme['name']."х".$item[2].'</div>';
                            
}else{
                                
mysql_query("INSERT INTO `inventory`(
                                    `name`,
                                    `type`,
                                    `feature_pover`,
                                    `feature_vitality`,
                                    `feature_dexterity`,
                                    `feature_wit`,
                                    `feature_spirit`,
                                    `feature_armor_arrow`,
                                    `feature_armor_weapon`,
                                    `feature_armor_magic`,
                                    `feature_attack_arrow`,
                                    `feature_attack_weapon`,
                                    `feature_attack_magic`,
                                    `feature_hp_regen`,
                                    `feature_mp_regen`,
                                    `cast_hp_regen`,
                                    `cast_mp_regen`,
                                    `min_lvl`,
                                    `coast`,
                                    `about`,
                                    `icon`,
                                    `attack_min_damag`,
                                    `attack_max_damag`,
                                    `account`,
                                    `twohands`,
                                    `subtype`,
                                    `ident_id`) VALUES (
                                    '"
.$iteme['name']."',
                                    '"
.$iteme['type']."',
                                    '"
.$iteme['feature_pover']."',
                                    '"
.$iteme['feature_vitality']."',
                                    '"
.$iteme['feature_dexterity']."',
                                    '"
.$iteme['feature_wit']."',
                                    '"
.$iteme['feature_spirit']."',
                                    '"
.$iteme['feature_armor_arrow']."',
                                    '"
.$iteme['feature_armor_weapon']."',
                                    '"
.$iteme['feature_armor_magic']."',
                                    '"
.$iteme['feature_attack_arrow']."',
                                    '"
.$iteme['feature_attack_weapon']."',
                                    '"
.$iteme['feature_attack_magic']."',
                                    '"
.$iteme['feature_hp_regen']."',
                                    '"
.$iteme['feature_mp_regen']."',
                                    '"
.$iteme['cast_hp_regen']."',
                                    '"
.$iteme['cast_mp_regen']."',
                                    '"
.$iteme['min_lvl']."',
                                    '"
.$iteme['coast']."',
                                    '"
.$iteme['about']."',
                                    '"
.$iteme['icon']."',
                                    '"
.$iteme['attack_min_damag']."',
                                    '"
.$iteme['attack_max_damag']."',
                                    '"
.$account['id']."',
                                    '"
.$iteme['twohands']."',
                                    '"
.$iteme['subtype']."',
                                    '"
.$iteme['id']."')") or die(mysql_error());
                                    
mysql_query("UPDATE `account` SET `gold`=`gold`-'".$item[1]."'");
                                    echo 
'<div class="help">Получен предмет: '.$iteme['name'].'</div>';
                            }
                            }else{
                            if (
$account['gold']>$item[1]){
                                
//зарос
                                
mysql_query("INSERT INTO `inventory`(
                                    `name`,
                                    `type`,
                                    `feature_pover`,
                                    `feature_vitality`,
                                    `feature_dexterity`,
                                    `feature_wit`,
                                    `feature_spirit`,
                                    `feature_armor_arrow`,
                                    `feature_armor_weapon`,
                                    `feature_armor_magic`,
                                    `feature_attack_arrow`,
                                    `feature_attack_weapon`,
                                    `feature_attack_magic`,
                                    `feature_hp_regen`,
                                    `feature_mp_regen`,
                                    `cast_hp_regen`,
                                    `cast_mp_regen`,
                                    `min_lvl`,
                                    `coast`,
                                    `about`,
                                    `icon`,
                                    `attack_min_damag`,
                                    `attack_max_damag`,
                                    `account`,
                                    `twohands`,
                                    `subtype`,
                                    `ident_id`) VALUES (
                                    '"
.$iteme['name']."',
                                    '"
.$iteme['type']."',
                                    '"
.$iteme['feature_pover']."',
                                    '"
.$iteme['feature_vitality']."',
                                    '"
.$iteme['feature_dexterity']."',
                                    '"
.$iteme['feature_wit']."',
                                    '"
.$iteme['feature_spirit']."',
                                    '"
.$iteme['feature_armor_arrow']."',
                                    '"
.$iteme['feature_armor_weapon']."',
                                    '"
.$iteme['feature_armor_magic']."',
                                    '"
.$iteme['feature_attack_arrow']."',
                                    '"
.$iteme['feature_attack_weapon']."',
                                    '"
.$iteme['feature_attack_magic']."',
                                    '"
.$iteme['feature_hp_regen']."',
                                    '"
.$iteme['feature_mp_regen']."',
                                    '"
.$iteme['cast_hp_regen']."',
                                    '"
.$iteme['cast_mp_regen']."',
                                    '"
.$iteme['min_lvl']."',
                                    '"
.$iteme['coast']."',
                                    '"
.$iteme['about']."',
                                    '"
.$iteme['icon']."',
                                    '"
.$iteme['attack_min_damag']."',
                                    '"
.$iteme['attack_max_damag']."',
                                    '"
.$account['id']."',
                                    '"
.$iteme['twohands']."',
                                    '"
.$iteme['subtype']."',
                                    '"
.$iteme['id']."')") or die(mysql_error());
                                    
mysql_query("UPDATE `account` SET `gold`=`gold`-'".$item[1]."'");
                                    echo 
'<div class="help">Получен предмет: '.$iteme['name'].'</div>';
                            }else{
                                echo 
'<div class="help">Недостаточно золота</div>';
                            }
                            }
                        }else{
                            
header("Location: ?npc=".$npc['id']."&shop");
                    exit;
                        }
                        unset(
$item);
                }
                echo 
'<div class="tools">Торговля: '.(!isset($_GET['sell'])?'<a href="?npc='.$npc['id'].'&sell">Продать</a>':'Продать').
                | '
.(!isset($_GET['shop'])?'<a href="?npc='.$npc['id'].'&shop">Купить</a>':'Купить').'</div>';
                    
//////////////////////////////////////Торговля
                    
$drop=explode(',',$npc['items']);
                        foreach(
$drop as $value){
                            
$item=explode(':',$value);
                                
$iteme=mysql_fetch_assoc(mysql_query("SELECT * FROM `items` WHERE 
                                `id`='"
.$item[0]."'"));
                                if (
preg_match("/weapon/",$iteme['type'])){
                                    echo 
'<div class="border-top"></div>';
                                    echo 
'<div class="tools">';
            echo 
'<img src="/data/img/items/weapon/'.$iteme['icon'].'.jpg" style="float:left; margin-right:10px;" />';
            echo 
'<font color="#3d8e2f">'.htmlspecialchars(stripslashes($iteme['name'])).'</font>';
            echo 
'<br />';
            if (
$iteme['type']=='weapon_exe'){
                if(
$iteme['twohands']==1){
                    if (
$account['class']=='warrior'){
                        echo 
'Двуручный топор';
                    }else{
                        echo 
'<font color="#3d060c">Двуручный топор</font>';
                    }
                }else{
                    echo 
'Одноручный топор';
                }
            }elseif(
$iteme['type']=='weapon_blade'){
                    if(
$iteme['twohands']==1){
                        if (
$account['class']=='warrior'){
                            echo 
'Двуручный меч';
                        }else{
                            echo 
'<font color="#3d060c">Двуручный меч</font>';
                        }
                    }else{
                        echo 
'Одноручный меч';
                    }
            }elseif(
$iteme['type']=='weapon_onion'){
                if (
$account['class']=='rogue'){
                    echo 
'Лук';
                }else{
                    echo 
'<font color="#3d060c">Лук</font>';
                }
            }elseif(
$iteme['type']=='weapon_dadge'){
                if (
$account['class']=='rogue'){
                    echo 
'Кинжал';
                }else{
                    echo 
'<font color="#3d060c">Кинжал</font>';
                }
            }elseif(
$iteme['type']=='weapon_hammer'){
                if(
$iteme['twohands']==1){
                    if (
$account['class']=='warrior'){
                        echo 
'Двуручный молот';
                    }else{
                        echo 
'<font color="#3d060c">Двуручный молот</font>';
                    }
                }else{
                    echo 
'Одноручный молот';
                }
            }elseif(
$iteme['type']=='weapon_mace'){
                    echo 
'Булава';
            }elseif(
$iteme['type']=='weapon_magicsword'){
                    if (
$account['class']=='mage'){
                        echo 
'Магическое оружие';
                    }else{
                        echo 
'<font color="#3d060c">Магическое оружие</font>';
                    }
            }elseif(
$iteme['type']=='weapon_polearm'){
                    if(
$account['class']=='warrior'){
                        echo 
'Алебарда';
                    }else{
                        echo 
'<font color="#3d060c">Алебарда</font>';
                    }
            }elseif(
$iteme['type']=='weapon_staff'){
                    if (
$account['class']=='mage'){
                        echo 
'Посох';
                    }else{
                        echo 
'<font color="#3d060c">Посох</font>';
                    }
            }
            echo 
'<br /></div>';
            echo 
'<a class="link" href="?npc='.$npc['id'].'&shop&buy='.$iteme['id'].'">Купить ('.$item[1].')</a>';
            echo 
'<div class="help">';
            if (
$iteme['feature_pover']){
                echo 
'<font color="#344c64">Сила+'.$iteme['feature_pover'].'</font><br />';
            }
            if (
$iteme['feature_vitality']){
                echo 
'<font color="#344c64">Живучесть+'.$iteme['feature_vitality'].'</font><br />';
            }
            if (
$iteme['feature_dexterity']){
                echo 
'<font color="#344c64">Ловкость+'.$iteme['feature_dexterity'].'</font><br />';
            }
            if (
$iteme['feature_wit']){
                echo 
'<font color="#344c64">Ум+'.$iteme['feature_wit'].'</font><br />';
            }
            if (
$iteme['feature_spirit']){
                echo 
'<font color="#344c64">Дух+'.$iteme['feature_spirit'].'</font><br />';
            }
            if (
$iteme['feature_armor_arrow']){
                echo 
'Защита от стрел+'.$iteme['feature_armor_arrow'].'<br />';
            }
            if (
$iteme['feature_armor_weapon']){
                echo 
'Защита от оружия+'.$iteme['feature_armor_weapon'].'<br />';
            }
            if (
$iteme['feature_armor_magic']){
                echo 
'Защита от магии+'.$iteme['feature_armor_magic'].'<br />';
            }
            if (
$iteme['feature_attack_arrow']){
                echo 
'Урон от стрел+'.$iteme['feature_attack_arrow'].'<br />';
            }
            if (
$iteme['feature_attack_weapon']){
                echo 
'Урон от оружия+'.$iteme['feature_attack_weapon'].'<br />';
            }
            if (
$iteme['feature_attack_magic']){
                echo 
'Урон от магии+'.$iteme['feature_attack_magic'].'<br />';
            }
            if (
$iteme['feature_hp_regen']){
                echo 
'Восстановление жизни+'.$iteme['feature_hp_regen'].'<br />';
            }
            if (
$iteme['feature_mp_regen']){
                echo 
'Восстановление маны+'.$iteme['feature_mp_regen'].'<br />';
            }
            if (
$iteme['attack_min_damag'] && $iteme['attack_max_damag']){
                echo 
'Урон '.$iteme['attack_min_damag'].' - '.$iteme['attack_max_damag'].'<br />';
            }
            if (
$iteme['min_lvl']){
                if (
$account['lvl']>=$iteme['min_lvl']){
                    echo 
'Требуется уровень: '.$iteme['min_lvl'].'<br />';
                }else{
                    echo 
'<font color="#3d060c">Требуется уровень: '.$iteme['min_lvl'].'</font><br />';
                }
            }
            echo 
'</div><div class="help"><font color="#8e8171">'.htmlspecialchars(stripslashes($iteme['about'])).'</font></div>';
                                }elseif(
preg_match("/armor/",$iteme['type'])){
                                    echo 
'<div class="help">';
            echo 
'<img src="/data/img/items/armor/'.$iteme['icon'].'.jpg" style="float:left; margin-right:10px;" />';
            echo 
'<font color="#3d8e2f">'.htmlspecialchars(stripslashes($iteme['name'])).'</font>';
            echo 
'<br /">';
            if (
$iteme['type']=='armor_head'){
                echo 
'Шлем';
            }elseif(
$iteme['type']=='armor_body'){
                echo 
'Нагрудник';
            }elseif(
$iteme['type']=='armor_gloves'){
                echo 
'Перчатки';
            }elseif(
$iteme['type']=='armor_shoulder'){
                echo 
'Наплечники';
            }elseif(
$iteme['type']=='armor_belt'){
                echo 
'Пояс';
            }elseif(
$iteme['type']=='armor_neckleace'){
                echo 
'Ожерелье';
            }elseif(
$iteme['type']=='armor_ring'){
                echo 
'Кольцо';
            }elseif(
$iteme['type']=='armor_shield'){
                echo 
'Щит';
            }elseif(
$iteme['type']=='armor_earring'){
                echo 
'Серьги';
            }elseif(
$iteme['type']=='armor_boots'){
                echo 
'Ботинки';
            }
            if (
$iteme['subtype']){
                if (
$iteme['subtype']=='armor'){
                    if (
$account['class']=='warrior'){
                        echo 
' Латы';
                    }else{
                        echo 
' <font color="#3d060c">Латы</font>';
                    }
                }elseif(
$iteme['subtype']=='skin'){
                    if (
$account['class']=='rogue'){
                        echo 
' Кожа';
                    }else{
                        echo 
' <font color="#3d060c">Кожа</font>';
                    }
                }elseif(
$iteme['subtype']=='fabric'){
                    if (
$account['class']=='mage'){
                        echo 
' Ткань';
                    }else{
                        echo 
' <font color="#3d060c">Ткань</font>';
                    }
                }
            }
            echo 
'<br /></div>';
            echo 
'<a class="link" href="?npc='.$npc['id'].'&shop&buy='.$iteme['id'].'">Купить ('.$item[1].')</a>';
            echo 
'<div class="help">';
            if (
$iteme['feature_pover']){
                echo 
'<font color="#344c64">Сила+'.$iteme['feature_pover'].'</font><br />';
            }
            if (
$iteme['feature_vitality']){
                echo 
'<font color="#344c64">Живучесть+'.$iteme['feature_vitality'].'</font><br />';
            }
            if (
$iteme['feature_dexterity']){
                echo 
'<font color="#344c64">Ловкость+'.$iteme['feature_dexterity'].'</font><br />';
            }
            if (
$iteme['feature_wit']){
                echo 
'<font color="#344c64">Ум+'.$iteme['feature_wit'].'</font><br />';
            }
            if (
$iteme['feature_spirit']){
                echo 
'<font color="#344c64">Дух+'.$iteme['feature_spirit'].'</font><br />';
            }
            if (
$iteme['feature_armor_arrow']){
                echo 
'Защита от стрел+'.$iteme['feature_armor_arrow'].'<br />';
            }
            if (
$iteme['feature_armor_weapon']){
                echo 
'Защита от оружия+'.$iteme['feature_armor_weapon'].'<br />';
            }
            if (
$iteme['feature_armor_magic']){
                echo 
'Защита от магии+'.$iteme['feature_armor_magic'].'<br />';
            }
            if (
$iteme['feature_attack_arrow']){
                echo 
'Урон от стрел+'.$iteme['feature_attack_arrow'].'<br />';
            }
            if (
$iteme['feature_attack_weapon']){
                echo 
'Урон от оружия+'.$iteme['feature_attack_weapon'].'<br />';
            }
            if (
$iteme['feature_attack_magic']){
                echo 
'Урон от магии+'.$iteme['feature_attack_magic'].'<br />';
            }
            if (
$iteme['feature_hp_regen']){
                echo 
'Восстановление жизни+'.$iteme['feature_hp_regen'].'<br />';
            }
            if (
$iteme['feature_mp_regen']){
                echo 
'Восстановление маны+'.$iteme['feature_mp_regen'].'<br />';
            }
            if (
$iteme['attack_min_damag'] && $iteme['attack_max_damag']){
                echo 
'Урон '.$iteme['attack_min_damag'].' - '.$iteme['attack_max_damag'].'<br />';
            }
            if (
$iteme['min_lvl']){
                if (
$account['lvl']>=$iteme['min_lvl']){
                    echo 
'Требуется уровень: '.$iteme['min_lvl'].'<br />';
                }else{
                    echo 
'<font color="#3d060c">Требуется уровень: '.$iteme['min_lvl'].'</font><br />';
                }
            }
            echo 
'</div><div class="help">';
            echo 
'<font color="#8e8171">'.htmlspecialchars(stripslashes($iteme['about'])).'</font>';
            echo 
'</div>';
                                }elseif(
preg_match("/eat/",$iteme['type'])){
                                
                                    echo 
'<div class="help">';
            echo 
'<img src="/data/img/items/eat/'.$iteme['icon'].'.jpg" style="float:left;margin-right:10px;"/>';
            echo 
'<font color="#3d8e2f">'.htmlspecialchars(stripslashes($iteme['name'])).'</font>';
            if (
$iteme['amount']>1){
                echo 
' ('.$iteme['amount'].')';
            }
            echo 
'</div><a class="link" href="?npc='.$npc['id'].'&shop&buy='.$iteme['id'].'">Купить ('.$item[1].')</a>';
            echo 
'<div class="help">';
            if (
$iteme['cast_hp_regen']){
                echo 
'Восстановление жизни+'.$iteme['cast_hp_regen'].'<br />';
            }
            if (
$iteme['cast_mp_regen']){
                echo 
'Восстановление маны+'.$iteme['cast_mp_regen'].'<br />';
            }
            echo 
'</div><div class="help">';
            echo 
'<font color="#cbbd36">'.htmlspecialchars(stripslashes($iteme['about'])).'</font></div>';
                                }
                            unset(
$iteme);
                            unset(
$item);
                        }
                    
                    
                    
//////////////////////////////////////
                    
echo '<div class="nstr">';
                    echo 
'<a class="navi" href="?npc='.$npc['id'].'">Назад</a>';
                    echo 
'<a class="navi" href="?">Локация</a>';
                    echo 
'</div>';
                    
down();
                    exit;
                }else{
                    
header("Location: ?npc=".$npc['id']);
                    exit;
                }
            }elseif(isset(
$_GET['sell'])){
                if (isset(
$_GET['sel'])){
                    if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `inventory` WHERE `account`='".$account['id']."' AND `id`='".intval($_GET['sel'])."'"),0)){
                        
$itemsell=mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `account`='".$account['id']."' AND `id`='".intval($_GET['sel'])."'"));
                        if(
preg_match("/eat/",$itemsell['type'])){
                            if (
$itemsell['amount']){
                                
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".($itemsell['amount']*$itemsell['coast'])." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.($itemsell['amount']*$itemsell['coast']).'</div>';
                            }else{
                                
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                            }
                            
                        }elseif(
preg_match("/weapon/",$itemsell['type'])){
                            if (
$account['weapon_right']==$itemsell['id'] || $account['weaponshield_left']==$itemsell['id']){
                                
                                }else{
                                
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                                }
                        }elseif(
preg_match("/armor/",$itemsell['type'])){
                            if (
$itemsell['type']=='armor_ring'){
                if(
$account['armor_ring']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
            }else{
                if (
$itemsell['type']=='armor_head'){
                    if(
$account['armor_head']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='armor_body'){
                    if(
$account['armor_body']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='armor_gloves'){
                    if(
$account['armor_gloves']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='armor_shoulder'){
                    if(
$account['armor_shoulder']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='armor_belt'){
                    if(
$account['armor_belt']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='armor_neckleace'){
                    if(
$account['armor_neckleace']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='weaponshield_left'){
                    if(
$account['armor_shield']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }elseif(
$itemsell['type']=='armor_earring'){
                    if(
$account['armor_earring']==$itemsell['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
mysql_query("DELETE FROM `inventory` WHERE `id`='".$itemsell['id']."'");
                                
mysql_query("UPDATE `account` SET `gold`=`gold`+".$itemsell['coast']." WHERE `id`='".$account['id']."'");
                                echo 
'<div class="help">Предмет продан</div>';
                                echo 
'<div class="help">Получено золота: '.$itemsell['coast'].'</div>';
                    }
                }
            }
                        }
                    }
                }
                echo 
'<div class="tools">Торговля: '.(!isset($_GET['sell'])?'<a href="?npc='.$npc['id'].'&sell">Продать</a>':'Продать').' |
                '
.(!isset($_GET['shop'])?'<a href="?npc='.$npc['id'].'&shop">Купить</a>':'Купить').'</div>';
                echo 
'<div class="tools">Вещи: '.((isset($_GET['eat']) || isset($_GET['armor']))?'<a href="?npc='.$npc['id'].'&sell">Оружие</a>':'Оружие').
                | '
.((!isset($_GET['weapon']) && !isset($_GET['eat']) && isset($_GET['armor']))?'Броня':'<a href="?npc='.$npc['id'].'&sell&armor">Броня</a>').
                | '
.((!isset($_GET['armor']) && !isset($_GET['weapon']) && isset($_GET['eat']))?'Еда и питье':'<a href="?npc='.$npc['id'].'&sell&eat">Еда и питье</a>').'</div>';
                if (isset(
$_GET['armor'])){
                    
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `inventory` WHERE `account`='".$account['id']."' AND `type` LIKE 'armor_%'"),0);
        
$page=intval($_GET['page']);
        
$cop=3;
        
$cp=ceil($ca/$cop);
        if (
$page<=0){
            
$page=1;
        }elseif(
$page>$cp){
            
$page=$cp;
        }
        
$start=($page*$cop)-$cop;
        
$q=mysql_query("SELECT * FROM `inventory` WHERE `account`='".$account['id']."' AND `type` LIKE 'armor_%' LIMIT $start,$cop");
        
$call=0;
        while(
$result=mysql_fetch_array($q)){
            if (
$result['type']=='armor_ring'){
                if(
$account['armor_ring']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
                    }
            }else{
                if (
$result['type']=='armor_head'){
                    if(
$account['armor_head']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
                    }
                }elseif(
$result['type']=='armor_body'){
                    if(
$account['armor_body']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
                    }
                }elseif(
$result['type']=='armor_gloves'){
                    if(
$account['armor_gloves']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
                    }
                }elseif(
$result['type']=='armor_shoulder'){
                    if(
$account['armor_shoulder']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
                    }
                }elseif(
$result['type']=='armor_belt'){
                    if(
$account['armor_belt']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                        
                    }
                }elseif(
$result['type']=='armor_neckleace'){
                    if(
$account['armor_neckleace']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                    }
                }elseif(
$result['type']=='weaponshield_left'){
                    if(
$account['armor_shield']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                    }
                }elseif(
$result['type']=='armor_earring'){
                    if(
$account['armor_earring']==$result['id']){
                        
//echo ' <font color="gray">(Снаряжено)</font>';
                        
continue;
                    }else{
                    }
                }
            }
            
$call++;
            echo 
'<div class="border-top"></div>';
            echo 
'<div class="help">';
            echo 
'<img src="/data/img/items/armor/'.$result['icon'].'.jpg" style="float:left; margin-right:10px;" />';
            echo 
'<font color="#3d8e2f">'.htmlspecialchars(stripslashes($result['name'])).'</font>';
            echo 
'<br /">';
            if (
$result['type']=='armor_head'){
                echo 
'Шлем';
            }elseif(
$result['type']=='armor_body'){
                echo 
'Нагрудник';
            }elseif(
$result['type']=='armor_gloves'){
                echo 
'Перчатки';
            }elseif(
$result['type']=='armor_shoulder'){
                echo 
'Наплечники';
            }elseif(
$result['type']=='armor_belt'){
                echo 
'Пояс';
            }elseif(
$result['type']=='armor_neckleace'){
                echo 
'Ожерелье';
            }elseif(
$result['type']=='armor_ring'){
                echo 
'Кольцо';
            }elseif(
$result['type']=='armor_shield'){
                echo 
'Щит';
            }elseif(
$result['type']=='armor_earring'){
                echo 
'Серьги';
            }elseif(
$result['type']=='armor_boots'){
                echo 
'Ботинки';
            }
            if (
$result['subtype']){
                if (
$result['subtype']=='armor'){
                    if (
$account['class']=='warrior'){
                        echo 
' Латы';
                    }else{
                        echo 
' <font color="#3d060c">Латы</font>';
                    }
                }elseif(
$result['subtype']=='skin'){
                    if (
$account['class']=='rogue'){
                        echo 
' Кожа';
                    }else{
                        echo 
' <font color="#3d060c">Кожа</font>';
                    }
                }elseif(
$result['subtype']=='fabric'){
                    if (
$account['class']=='mage'){
                        echo 
' Ткань';
                    }else{
                        echo 
' <font color="#3d060c">Ткань</font>';
                    }
                }
            }
            echo 
'<br />';
            echo 
'</div>';
            echo 
'<a class="link" href="?npc='.$npc['id'].'&sell&armor&page='.$page.'&sel='.$result['id'].'">Продать ('.$result['coast'].')</a>';
            
//echo '<div class="link"><a href="?act=armor&get_out='.$result['id'].'">Выбросить</a></div>';
            
echo '<div class="help">';
            if (
$result['feature_pover']){
                echo 
'<font color="#344c64">Сила+'.$result['feature_pover'].'</font><br />';
            }
            if (
$result['feature_vitality']){
                echo 
'<font color="#344c64">Живучесть+'.$result['feature_vitality'].'</font><br />';
            }
            if (
$result['feature_dexterity']){
                echo 
'<font color="#344c64">Ловкость+'.$result['feature_dexterity'].'</font><br />';
            }
            if (
$result['feature_wit']){
                echo 
'<font color="#344c64">Ум+'.$result['feature_wit'].'</font><br />';
            }
            if (
$result['feature_spirit']){
                echo 
'<font color="#344c64">Дух+'.$result['feature_spirit'].'</font><br />';
            }
            if (
$result['feature_armor_arrow']){
                echo 
'Защита от стрел+'.$result['feature_armor_arrow'].'<br />';
            }
            if (
$result['feature_armor_weapon']){
                echo 
'Защита от оружия+'.$result['feature_armor_weapon'].'<br />';
            }
            if (
$result['feature_armor_magic']){
                echo 
'Защита от магии+'.$result['feature_armor_magic'].'<br />';
            }
            if (
$result['feature_attack_arrow']){
                echo 
'Урон от стрел+'.$result['feature_attack_arrow'].'<br />';
            }
            if (
$result['feature_attack_weapon']){
                echo 
'Урон от оружия+'.$result['feature_attack_weapon'].'<br />';
            }
            if (
$result['feature_attack_magic']){
                echo 
'Урон от магии+'.$result['feature_attack_magic'].'<br />';
            }
            if (
$result['feature_hp_regen']){
                echo 
'Восстановление жизни+'.$result['feature_hp_regen'].'<br />';
            }
            if (
$result['feature_mp_regen']){
                echo 
'Восстановление маны+'.$result['feature_mp_regen'].'<br />';
            }
            if (
$result['attack_min_damag'] && $result['attack_max_damag']){
                echo 
'Урон '.$result['attack_min_damag'].' - '.$result['attack_max_damag'].'<br />';
            }
            if (
$result['min_lvl']){
                if (
$account['lvl']>=$result['min_lvl']){
                    echo 
'Требуется уровень: '.$result['min_lvl'].'<br />';
                }else{
                    echo 
'<font color="#3d060c">Требуется уровень: '.$result['min_lvl'].'</font><br />';
                }
            }
            echo 
'</div><div class="help">';
            echo 
'<font color="#8e8171">'.htmlspecialchars(stripslashes($result['about'])).'</font></div>';
        }
        if (!
$call){
            echo 
'<div class="border-top"></div><div class="help">У вас нет брони, которую можно продать</div>';
        }
        echo 
'<div class="nstr">';
        echo 
'Страница ';
        if (
$page-1>=1){
            echo 
'<a href="?armor&npc='.$npc['id'].'&sell&page='.($page-1).'"><</a>';
        }
        if (
$page-1>=1){
            echo 
'<a href="?armor&npc='.$npc['id'].'&sell&page='.($page-1).'">'.($page-1).'</a>';
        }
        echo 
'<b>'.$page.'</b>';
        if (
$page+1<=$cp){
            echo 
'<a href="?armor&npc='.$npc['id'].'&sell&page='.($page+1).'">'.($page+1).'</a>';
        }
        if (
$page+1<=$cp){
            echo 
'<a href="?armor&npc='.$npc['id'].'&sell&page='.($page+1).'">></a>';
        }
        echo 
'</div>';
        
                }elseif(isset(
$_GET['eat'])){
                    
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `inventory` WHERE `account`='".$account['id']."' AND `type` LIKE 'eat_%'"),0);
        
$page=intval($_GET['page']);
        
$cop=3;
        
$cp=ceil($ca/$cop);
        if (
$page<=0){
            
$page=1;
        }elseif(
$page>$cp){
            
$page=$cp;
        }
        
$start=($page*$cop)-$cop;
        
$q=mysql_query("SELECT * FROM `inventory` WHERE `account`='".$account['id']."' AND `type` LIKE 'eat_%' LIMIT $start,$cop");
        if(
$ca==0){
            echo 
'<div class="border-top"></div><div class="help">У вас нет ни еды, ни питья, которое можно продать</div>';
        }
        while(
$result=mysql_fetch_array($q)){
            echo 
'<div class="border-top"></div>';
            echo 
'<div class="help">';
            echo 
'<img src="/data/img/items/eat/'.$result['icon'].'.jpg" style="float:left;margin-right:10px;"/>';
            echo 
'<font color="#3d8e2f">'.htmlspecialchars(stripslashes($result['name'])).'</font>';
            if (
$result['amount']>1){
                echo 
' ('.$result['amount'].')';
            }
            echo 
'<br /></div><a class="link" href="?npc='.$npc['id'].'&sell&eat&page='.$page.'&sel='.$result['id'].'">Продать ('.$result['coast'].')</a>';
            
//echo '<div class="link"><a href="?act=eat&get_out='.$result['id'].'">Выбросить</a></div>';
            
echo '<div class="help">';
            if (
$result['cast_hp_regen']){
                echo 
'Восстановление жизни+'.$result['cast_hp_regen'].'<br />';
            }
            if (
$result['cast_mp_regen']){
                echo 
'Восстановление маны+'.$result['cast_mp_regen'].'<br />';
            }
            echo 
'</div><div class="help">';
            echo 
'<font color="#cbbd36">'.htmlspecialchars(stripslashes($result['about'])).'</font></div>';
        }
        echo 
'<div class="nstr">';
        echo 
'Страница ';
        if (
$page-1>=1){
            echo 
'<a href="?npc='.$npc['id'].'&sell&eat&page='.($page-1).'"><</a>';
        }
        if (
$page-1>=1){
            echo 
'<a href="?npc='.$npc['id'].'&sell&eat&page='.($page-1).'">'.($page-1).'</a>';
        }
        echo 
'<b>'.$page.'</b>';
        if (
$page+1<=$cp){
            echo 
'<a href="?npc='.$npc['id'].'&sell&eat&page='.($page+1).'">'.($page+1).'</a>';
        }
        if (
$page+1<=$cp){
            echo 
'<a href="?npc='.$npc['id'].'&sell&eat&page='.($page+1).'">></a>';
        }
        echo 
'</div>';
                }else{
                    
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `inventory` WHERE `account`='".$account['id']."' AND `type` LIKE 'weapon_%'"),0);
        
$page=intval($_GET['page']);
        
$cop=3;
        
$cp=ceil($ca/$cop);
        if (
$page<=0){
            
$page=1;
        }elseif(
$page>$cp){
            
$page=$cp;
        }
        
$start=($page*$cop)-$cop;
        
$q=mysql_query("SELECT * FROM `inventory` WHERE `account`='".$account['id']."' AND `type` LIKE 'weapon_%' LIMIT $start,$cop");
        
$call=0;
        while(
$result=mysql_fetch_array($q)){
            if (
$account['weapon_right']!=$result['id'] && $account['weaponshield_left']!=$result['id']){
            
$call++;
            echo 
'<div class="border-top"></div>';
            echo 
'<div class="help">';
            echo 
'<img src="/data/img/items/weapon/'.$result['icon'].'.jpg" style="float:left; margin-right:10px;" />';
            echo 
'<font color="#3d8e2f">'.htmlspecialchars(stripslashes($result['name'])).'</font>';
            echo 
'<br />';
            if (
$result['type']=='weapon_axe'){
                if(
$result['twohands']==1){
                    if (
$account['class']=='warrior'){
                        echo 
'Двуручный топор';
                    }else{
                        echo 
'<font color="#3d060c">Двуручный топор</font>';
                    }
                }else{
                    echo 
'Одноручный топор';
                }
            }elseif(
$result['type']=='weapon_blade'){
                    if(
$result['twohands']==1){
                        if (
$account['class']=='warrior'){
                            echo 
'Двуручный меч';
                        }else{
                            echo 
'<font color="#3d060c">Двуручный меч</font>';
                        }
                    }else{
                        echo 
'Одноручный меч';
                    }
            }elseif(
$result['type']=='weapon_onion'){
                if (
$account['class']=='rogue'){
                    echo 
'Лук';
                }else{
                    echo 
'<font color="#3d060c">Лук</font>';
                }
            }elseif(
$result['type']=='weapon_dadge'){
                if (
$account['class']=='rogue'){
                    echo 
'Кинжал';
                }else{
                    echo 
'<font color="#3d060c">Кинжал</font>';
                }
            }elseif(
$result['type']=='weapon_hammer'){
                if(
$result['twohands']==1){
                    if (
$account['class']=='warrior'){
                        echo 
'Двуручный молот';
                    }else{
                        echo 
'<font color="#3d060c">Двуручный молот</font>';
                    }
                }else{
                    echo 
'Одноручный молот';
                }
            }elseif(
$result['type']=='weapon_mace'){
                    echo 
'Булава';
            }elseif(
$result['type']=='weapon_magicsword'){
                    if (
$account['class']=='mage'){
                        echo 
'Магическое оружие';
                    }else{
                        echo 
'<font color="#3d060c">Магическое оружие</font>';
                    }
            }elseif(
$result['type']=='weapon_polearm'){
                    if(
$account['class']=='warrior'){
                        echo 
'Алебарда';
                    }else{
                        echo 
'<font color="#3d060c">Алебарда</font>';
                    }
            }elseif(
$result['type']=='weapon_staff'){
                    if (
$account['class']=='mage'){
                        echo 
'Посох';
                    }else{
                        echo 
'<font color="#3d060c">Посох</font>';
                    }
            }
            echo 
'<br /></div>';
            
            echo 
'<a class="link" href="?npc='.$npc['id'].'&sell&weapon&page='.$page.'&sel='.$result['id'].'">Продать ('.$result['coast'].')</a>';
            
//echo '<div class="link"><a href="?act=weapon&get_out='.$result['id'].'">Выбросить</a></div>';
            
echo '<div class="help">';
            if (
$result['feature_pover']){
                echo 
'<font color="#344c64">Сила+'.$result['feature_pover'].'</font><br />';
            }
            if (
$result['feature_vitality']){
                echo 
'<font color="#344c64">Живучесть+'.$result['feature_vitality'].'</font><br />';
            }
            if (
$result['feature_dexterity']){
                echo 
'<font color="#344c64">Ловкость+'.$result['feature_dexterity'].'</font><br />';
            }
            if (
$result['feature_wit']){
                echo 
'<font color="#344c64">Ум+'.$result['feature_wit'].'</font><br />';
            }
            if (
$result['feature_spirit']){
                echo 
'<font color="#344c64">Дух+'.$result['feature_spirit'].'</font><br />';
            }
            if (
$result['feature_armor_arrow']){
                echo 
'Защита от стрел+'.$result['feature_armor_arrow'].'<br />';
            }
            if (
$result['feature_armor_weapon']){
                echo 
'Защита от оружия+'.$result['feature_armor_weapon'].'<br />';
            }
            if (
$result['feature_armor_magic']){
                echo 
'Защита от магии+'.$result['feature_armor_magic'].'<br />';
            }
            if (
$result['feature_attack_arrow']){
                echo 
'Урон от стрел+'.$result['feature_attack_arrow'].'<br />';
            }
            if (
$result['feature_attack_weapon']){
                echo 
'Урон от оружия+'.$result['feature_attack_weapon'].'<br />';
            }
            if (
$result['feature_attack_magic']){
                echo 
'Урон от магии+'.$result['feature_attack_magic'].'<br />';
            }
            if (
$result['feature_hp_regen']){
                echo 
'Восстановление жизни+'.$result['feature_hp_regen'].'<br />';
            }
            if (
$result['feature_mp_regen']){
                echo 
'Восстановление маны+'.$result['feature_mp_regen'].'<br />';
            }
            if (
$result['attack_min_damag'] && $result['attack_max_damag']){
                echo 
'Урон '.$result['attack_min_damag'].' - '.$result['attack_max_damag'].'<br />';
            }
            if (
$result['min_lvl']){
                if (
$account['lvl']>=$result['min_lvl']){
                    echo 
'Требуется уровень: '.$result['min_lvl'].'<br />';
                }else{
                    echo 
'<font color="#3d060c">Требуется уровень: '.$result['min_lvl'].'</font><br />';
                }
            }
            echo 
'</div><div class="help"><font color="#8e8171">'.htmlspecialchars(stripslashes($result['about'])).'</font></div>';
            }
        }
        if (!
$call){
            echo 
'<div class="border-top"></div><div class="help">У вас нет оружия, которое можно продать</div>';
        }
        echo 
'<div class="nstr">';
        echo 
'Страница ';
        if (
$page-1>=1){
            echo 
'<a href="?npc='.$npc['id'].'&sell&page='.($page-1).'"><</a>';
        }
        if (
$page-1>=1){
            echo 
'<a href="?npc='.$npc['id'].'&sell&page='.($page-1).'">'.($page-1).'</a>';
        }
        echo 
'<b>'.$page.'</b>';
        if (
$page+1<=$cp){
            echo 
'<a href="?npc='.$npc['id'].'&sell&page='.($page+1).'">'.($page+1).'</a>';
        }
        if (
$page+1<=$cp){
            echo 
'<a href="?npc='.$npc['id'].'&sell&page='.($page+1).'">></a>';
        }
        echo 
'</div>';
                }
                echo 
'<div class="nstr">';
                echo 
'<a class="navi" href="?npc='.$npc['id'].'">Назад</a>';
                echo 
'<a class="navi" href="?">Локация</a>';
                echo 
'</div>';
                
down();
                exit;
            }
            if (isset(
$_GET['talk']) && is_numeric($_GET['talk'])){
                echo 
'<div class="border-top"></div>';
                
$talk=intval($_GET['talk']);
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `dialogs` WHERE `npc`='".$npc['id']."' AND `id`='".$talk."'"),0)){
                    
$talk=mysql_fetch_array(mysql_query("SELECT * FROM `dialogs` WHERE `npc`='".$npc['id']."' AND `id`='".$talk."'"));
                    if (
$talk['quest_need_complete']){
                        if (!
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$talk['quest_need_complete']."' AND `account`='".$account['id']."' AND `completed`='1' AND `complet`='0'"),0)){
                            
header("Location: ?npc=".$npc['id']);
                            exit;
                        }
                    }
                    if (
$talk['quest_need_be_completed']){
                        if (!
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$talk['quest_need_complete']."' AND `account`='".$account['id']."' AND `completed`='1' AND `complet`='1'"),0)){
                            
header("Location: ?npc=".$npc['id']);
                            exit;
                        }
                    }
                    if (
$talk['quest_completed']){
                        if (!
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$talk['quest_completed']."' AND `account`='".$account['id']."' AND `completed`='1' AND `complet`='0'"),0)){
                            
header("Location: ?npc=".$npc['id']);
                            exit;
                        }else{
                            
mysql_query("UPDATE `quests` SET `complet`='1' WHERE `quest`='".$talk['quest_completed']."' AND `account`='".$account['id']."'");
                            
$queste_complete=mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id`='".$talk['quest_completed']."'"));
                            echo 
'<div class="help">Задание завершено</div>';
                            echo 
'<div class="help">Получено золота: '.$queste_complete['gold'].'</div>';
                            echo 
'<div class="help">Получено опыта: '.$queste_complete['exp'].'</div>';
                            
////////////////////////////////////////
                            
if ($queste_complete['items']){
                        
$drop=explode(',',$queste_complete['items']);
                        foreach(
$drop as $value){
                            
$item=explode(':',$value);
                                
$iteme=mysql_fetch_assoc(mysql_query("SELECT * FROM `items` WHERE 
                                `id`='"
.$item[0]."'"));
                                if (
$iteme['type']=='eat_bootle' OR $iteme['type']=='eat_eat' OR $iteme['type']=='resourse'){
                                    if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `inventory` WHERE 
                                        `ident_id`='"
.$iteme['id']."'
                                         AND `account`='"
.$mobe['battle_attack']."'"),0)){
                                        if (isset(
$item[2])){
                                            
mysql_query("UPDATE `inventory` SET 
                                            `amount`=`amount` + '"
.$item[2]."' 
                                            WHERE
                                            `ident_id`='"
.$iteme['id']."'
                                            AND `account`='"
.$mobe['battle_attack']."'");
                                            echo 
'<div class="help">Получен предмет: '.$iteme['name']."х".$item[2].'</div>';
                                            
//mysql_query("INSERT INTO `msg_list`(`acount`,`msg`)VALUES('".$targett['id']."','<div class="mesg">Получен предмет: ".$iteme['name']."х".$item[2]."</div>')");
                                        
}else{
                                            
mysql_query("UPDATE `inventory` SET 
                                            `amount`=`amount` + '1' 
                                            WHERE
                                            `ident_id`='"
.$iteme['id']."'
                                            AND `account`='"
.$mobe['battle_attack']."'");
                                            echo 
'<div class="help">Получен предмет: '.$iteme['name'].'</div>';
                                            
//mysql_query("INSERT INTO `msg_list`(`acount`,`msg`)VALUES('".$targett['id']."','<div class="mesg">Получен предмет: ".$iteme['name']."</div>')");
                                        
}
                                    }else{
                                        
mysql_query("INSERT INTO `inventory`(
                                        `name`,
                                        `type`,
                                        `feature_pover`,
                                        `feature_vitality`,
                                        `feature_dexterity`,
                                        `feature_wit`,
                                        `feature_spirit`,
                                        `feature_armor_arrow`,
                                        `feature_armor_weapon`,
                                        `feature_armor_magic`,
                                        `feature_attack_arrow`,
                                        `feature_attack_weapon`,
                                        `feature_attack_magic`,
                                        `feature_hp_regen`,
                                        `feature_mp_regen`,
                                        `cast_hp_regen`,
                                        `cast_mp_regen`,
                                        `min_lvl`,
                                        `amount`,
                                        `coast`,
                                        `about`,
                                        `icon`,
                                        `attack_min_damag`,
                                        `attack_max_damag`,
                                        `account`,
                                        `twohands`,
                                        `subtype`,
                                        `ident_id`) VALUES (
                                        '"
.$iteme['name']."',
                                        '"
.$iteme['type']."',
                                        '"
.$iteme['feature_pover']."',
                                        '"
.$iteme['feature_vitality']."',
                                        '"
.$iteme['feature_dexterity']."',
                                        '"
.$iteme['feature_wit']."',
                                        '"
.$iteme['feature_spirit']."',
                                        '"
.$iteme['feature_armor_arrow']."',
                                        '"
.$iteme['feature_armor_weapon']."',
                                        '"
.$iteme['feature_armor_magic']."',
                                        '"
.$iteme['feature_attack_arrow']."',
                                        '"
.$iteme['feature_attack_weapon']."',
                                        '"
.$iteme['feature_attack_magic']."',
                                        '"
.$iteme['feature_hp_regen']."',
                                        '"
.$iteme['feature_mp_regen']."',
                                        '"
.$iteme['cast_hp_regen']."',
                                        '"
.$iteme['cast_mp_regen']."',
                                        '"
.$iteme['min_lvl']."',
                                        '"
.$item[2]."',
                                        '"
.$iteme['coast']."',
                                        '"
.$iteme['about']."',
                                        '"
.$iteme['icon']."',
                                        '"
.$iteme['attack_min_damag']."',
                                        '"
.$iteme['attack_max_damag']."',
                                        '"
.$targett['id']."',
                                        '"
.$iteme['twohands']."',
                                        '"
.$iteme['subtype']."',
                                        '"
.$iteme['id']."')") or die(mysql_error());
                                        echo 
'<div class="help">Получен предмет: '.$iteme['name']."х".$item[2].'</div>';
                                        
//mysql_query("INSERT INTO `msg_list`(`acount`,`msg`)VALUES('".$targett['id']."','<div class="mesg">Получен предмет: ".$iteme['name']."</div>')");
                                    
}
                                }else{
                                    
mysql_query("INSERT INTO `inventory`(
                                    `name`,
                                    `type`,
                                    `feature_pover`,
                                    `feature_vitality`,
                                    `feature_dexterity`,
                                    `feature_wit`,
                                    `feature_spirit`,
                                    `feature_armor_arrow`,
                                    `feature_armor_weapon`,
                                    `feature_armor_magic`,
                                    `feature_attack_arrow`,
                                    `feature_attack_weapon`,
                                    `feature_attack_magic`,
                                    `feature_hp_regen`,
                                    `feature_mp_regen`,
                                    `cast_hp_regen`,
                                    `cast_mp_regen`,
                                    `min_lvl`,
                                    `coast`,
                                    `about`,
                                    `icon`,
                                    `attack_min_damag`,
                                    `attack_max_damag`,
                                    `account`,
                                    `twohands`,
                                    `subtype`,
                                    `ident_id`) VALUES (
                                    '"
.$iteme['name']."',
                                    '"
.$iteme['type']."',
                                    '"
.$iteme['feature_pover']."',
                                    '"
.$iteme['feature_vitality']."',
                                    '"
.$iteme['feature_dexterity']."',
                                    '"
.$iteme['feature_wit']."',
                                    '"
.$iteme['feature_spirit']."',
                                    '"
.$iteme['feature_armor_arrow']."',
                                    '"
.$iteme['feature_armor_weapon']."',
                                    '"
.$iteme['feature_armor_magic']."',
                                    '"
.$iteme['feature_attack_arrow']."',
                                    '"
.$iteme['feature_attack_weapon']."',
                                    '"
.$iteme['feature_attack_magic']."',
                                    '"
.$iteme['feature_hp_regen']."',
                                    '"
.$iteme['feature_mp_regen']."',
                                    '"
.$iteme['cast_hp_regen']."',
                                    '"
.$iteme['cast_mp_regen']."',
                                    '"
.$iteme['min_lvl']."',
                                    '"
.$iteme['coast']."',
                                    '"
.$iteme['about']."',
                                    '"
.$iteme['icon']."',
                                    '"
.$iteme['attack_min_damag']."',
                                    '"
.$iteme['attack_max_damag']."',
                                    '"
.$targett['id']."',
                                    '"
.$iteme['twohands']."',
                                    '"
.$iteme['subtype']."',
                                    '"
.$iteme['id']."')") or die(mysql_error());
                                    echo 
'<div class="help">Получен предмет: '.$iteme['name'].'</div>';
                                    
//mysql_query("INSERT INTO `msg_list`(`acount`,`msg`)VALUES('".$targett['id']."','<div class="mesg">Получен предмет: ".$iteme['name']."</div>')");
                                
}
                            unset(
$iteme);
                            unset(
$item);
                        }
                    }
                            
////////////////////////////////////
                        
}
                    }
                    if (
$talk['quest_need']){
                        if (!
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$talk['quest_need']."' AND `account`='".$account['id']."'"),0)){
                            
header("Location: ?npc=".$npc['id']);
                            exit;
                        }
                    }
                    if (
$talk['questd']){
                        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$talk['questd']."' AND `account`='".$account['id']."'"),0)){
                            
header("Location: ?npc=".$npc['id']);
                            exit;
                        }
                    }
                    if (
$talk['quest']){
                        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$talk['quest']."' AND `account`='".$account['id']."'"),0)){
                            
header("Location: ?npc=".$npc['id']);
                            exit;
                        }else{
                            
$quest=mysql_fetch_array(mysql_query("SELECT * FROM `quest` WHERE `id`='".$talk['quest']."'"));
                            
mysql_query("INSERT INTO `quests`(`quest`,`account`,`kill_mob`,`kill_mob_col`,`task`,`task_with`,`res_need`,`res_need_col`,`complet`) VALUES ('".$quest['id']."','".$account['id']."','".$quest['kill_mob']."','".$quest['kill_mob_col']."','".$quest['task']."','".$quest['task_with']."','".$quest['res_need']."','".$quest['res_need_col']."','0')");
                        }
                    }
                    echo 
'<div class="help"><img src="/data/img/units/npc/'.$npc['icon'].'.jpg" style="float:left;" height="24px" width="24px"><font color="#8e8171">'.$talk['talk_otvet_npc'].'</font><br /></div>';
                    
$resd=mysql_query("SELECT * FROM `dialogs` WHERE `npc`='".$npc['id']."' AND `talk_id_ref`='".$talk['id']."'");
                    while(
$result=mysql_fetch_array($resd)){
                        echo 
'<a class="link" href="?npc='.$npc['id'].'&talk='.$result['id'].'">'.$result['talk_name'].'</a>';
                    }
                    echo 
'<div class="nstr">';
                    if (isset(
$GET['talk'])){
                        echo 
'<a class="navi" href="?npc='.$npc['id'].'">Назад</a>';
                    }
                    if (
$npc['items']){
                        echo 
'<a class="navi" href="/location.php?npc='.$npc['id'].'&shop">Торговля</a>';
                    }
                    echo 
'<a class="navi" href="/location.php?">Локация</a>';
                    echo 
'</div>';
                    
down();
                    exit;
                }
            }
            echo 
'<div class="border-top"></div>';
            echo 
'<div class="help"><img src="/data/img/units/npc/'.$npc['icon'].'.jpg" style="float:left;" width="24px" height="24px"><font color="#8e8171">'.$npc['talk'].'</font><br /></div>';
            
$resd=mysql_query("SELECT * FROM `dialogs` WHERE `npc`='".$npc['id']."'");
            while(
$result=mysql_fetch_array($resd)){
                if (!
$result['talk_id_ref']){
                    if (
$result['questd']){
                        if (
$result['quest_need_be_completed']){
                            if (
mysql_result(mysql_query("SELECT * FROM `quests` WHERE `quest`='".$result['quest_need_be_completed']."' AND `account`='".$account['id']."' AND `complet`='1'"),0)){
                                if (!
mysql_result(mysql_query("SELECT * FROM `quests` WHERE `quest`='".$result['questd']."' AND `account`='".$account['id']."'"),0)){
                                    echo 
'<a class="link" href="?npc='.$npc['id'].'&talk='.$result['id'].'">'.$result['talk_name'].'</a>';
                                }
                            }
                        }elseif(!
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$result['questd']."' AND `account`='".$account['id']."'"),0)){
                            echo 
'<a class="link" href="?npc='.$npc['id'].'&talk='.$result['id'].'">'.$result['talk_name'].'</a>';
                        }else{
                        
//Empty
                        
}
                    }elseif(
$result['quest_need']){
                        if (
$result['quest_need_complete']){
                            if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$result['quest_need_complete']."' AND `account`='".$account['id']."' AND `completed`='1' AND `complet`='0'"),0)){
                                    echo 
'<a class="link" href="?npc='.$npc['id'].'&talk='.$result['id'].'">'.$result['talk_name'].'</a>';
                            }
                        }elseif(
mysql_result(mysql_query("SELECT COUNT(*) FROM `quests` WHERE `quest`='".$result['quest_need']."' AND `account`='".$account['id']."' AND `complet`='0'"),0)){
                            echo 
'<a class="link" href="?npc='.$npc['id'].'&talk='.$result['id'].'">'.$result['talk_name'].'</a>';
                        }else{ 
                        
//Empty
                        
}
                    }else{
                        echo 
'<a class="link" href="?npc='.$npc['id'].'&talk='.$result['id'].'">'.$result['talk_name'].'</a>';
                    }
                }
                
            }
            echo 
'<div class="nstr">';
                    if (isset(
$GET['talk'])){
                        echo 
'<a class="navi" href="?npc='.$npc['id'].'">Назад</a>';
                    }
                    if (
$npc['items']){
                        echo 
'<a class="navi" href="/location.php?npc='.$npc['id'].'&shop">Торговля</a>';
                    }
                    echo 
'<a class="navi" href="/location.php?">Локация</a>';
                    echo 
'</div>';
            
down();
            exit;
        }else{
            
header("Location: ?");
            exit;
        }
    }
    if (isset(
$_GET['x1']) && isset($_GET['y1']) && is_numeric($_GET['x1']) && is_numeric($_GET['y1'])){
        
$x1=intval($_GET['x1']);
        
$y1=intval($_GET['y1']);
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `mobs` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"),0)){
        
$mob=mysql_fetch_array(mysql_query("SELECT * FROM `mobs` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"));
        }
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `npc` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"),0)){
        
$npc=mysql_fetch_array(mysql_query("SELECT * FROM `mobs` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"));
        }
        if (!isset(
$mob) && !isset($npc)){
            if (
$account['x1']+1==$x1 && $account['y1']==$y1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND `cant_go`='0'  OR `cant_go`=''"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['x1']-1==$x1 && $account['y1']==$y1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['y1']+1==$y1 && $account['x1']==$x1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['y1']-1==$y1 && $account['x1']==$x1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['y1']+1==$y1 && $account['x1']+1==$x1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['y1']+1==$y1 && $account['x1']-1==$x1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['y1']-1==$y1 && $account['x1']-1==$x1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }elseif (
$account['y1']-1==$y1 && $account['x1']+1==$x1){
                if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$account['x']."' AND `y`='".$account['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){
                    
mysql_query("UPDATE `account` SET `x1`='".$x1."',`y1`='".$y1."' WHERE `id`='".$account['id']."'");
                }
                if (
mysql_result(mysql_query("SELECT `x_tp` FROM `sublocation` WHERE 
                    `x`='"
.$account['x']."' 
                    AND `y`='"
.$account['y']."' 
                    AND `x1`='"
.$x1."' 
                    AND `y1`='"
.$y1."'"),0)){
                
$loctp=mysql_fetch_assoc(mysql_query("SELECT * FROM `sublocation` WHERE 
                `x`='"
.$account['x']."' 
                AND `y`='"
.$account['y']."' 
                AND `x1`='"
.$x1."' 
                AND `y1`='"
.$y1."'"));
                
mysql_query("UPDATE `account` SET 
                `x`='"
.$loctp['x_tp']."',
                `y`='"
.$loctp['y_tp']."',
                `x1`='"
.$loctp['x1_tp']."',
                `y1`='"
.$loctp['y1_tp']."'
                WHERE 
                `id`='"
.$account['id']."'
                "
);
                }
                
header("Location: ?");
                exit;
            }    
        }
    }
    if (isset(
$_GET['duel'])){
        if (!
mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_add` WHERE `account`='".$account['id']."'"),0)){
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `account` WHERE `id`='".intval($_GET['duel'])."' AND '".time()."'-`last_active` <'360'"),0)){
            
$_usr=mysql_fetch_assoc(mysql_query("SELECT * FROM `account` WHERE `id`='".intval($_GET['duel'])."' AND '".time()."'-`last_active` <'360'"));
            if (!
$_usr['battle'] && !$_usr['duel_battle'] && !mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_add` WHERE `account`='".$_usr['id']."'"),0)){
                if (!
mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_add` WHERE `user`='".$account['id']."'"),0)){
                    if (
$_usr['x']==$account['x'] AND $_usr['y']==$account['y']){
                        
mysql_query("INSERT INTO `duel_add`(`user`,`account`)VALUES('".$account['id']."','".$_usr['id']."')");
                        echo 
'<div class="help">Вызов брошен</div>';
                    }else{
                        echo 
'<div class="help">Пользователь на другой локации</div>';
                    }
                }else{
                    echo 
'<div class="help">Вы уже бросили вызов</div>';
                }
            }else{
                echo 
'<div class="help">Пользователь в бою</div>';
            }
        }else{
            echo 
'<div class="help">Пользователя не существует или он оффлайн</div>';
        }
        }else{
            echo 
'<div class="help">Вас уже вызвали на дуэль</div>';
        }
    }
    if (isset(
$_GET['attack']) && is_numeric($_GET['attack'])){
        
$attack=intval($_GET['attack']);
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `mobs` WHERE `id`='".$attack."' AND `x`='".$location['x']."' AND `y`='".$location['y']."'"),0)){
            
$attack=mysql_fetch_array(mysql_query("SELECT * FROM `mobs` WHERE `id`='".$attack."' AND `x`='".$location['x']."' AND `y`='".$location['y']."'"));
            if (
time()-$attack['last_death']<$attack['death_time']){
                
header("Location: ?");
                exit;
            }
            if (
$attack['battle']){
                
mysql_query("UPDATE `account` SET `battle`='".$attack['battle']."',`battle_attack`='".$attack['id']."',`battle_target_type`='mob' WHERE `id`='".$account['id']."'");
                
mysql_query("DELETE FROM `battle_log` WHERE `account`='".$account['id']."'");
            }else{
                
mysql_query("INSERT INTO `battle` (`x`,`y`,`x1`,`y1`) VALUES ('".$location['x']."','".$location['y']."','".$x1."','".$y1."')");
                
$battle=mysql_insert_id();
                
mysql_query("DELETE FROM `battle_log` WHERE `account`='".$account['id']."'");
                
mysql_query("INSERT INTO `battle_log`(`account`,`mess`)VALUES('".$account['id']."','<div class="help">Бой начался!</div>')");
                
mysql_query("UPDATE `account` SET `battle`='".$battle."',`battle_attack`='".$attack['id']."',`battle_target_type`='mob' WHERE `id`='".$account['id']."'");
                
mysql_query("UPDATE `mobs` SET `battle`='".$battle."',`last_damag`='".time()."',`hp`='".$attack['max_hp']."',`battle_attack`='".$account['id']."' WHERE
                `id`='"
.$attack['id']."'");
                
$qat=mysql_query("SELECT * FROM `mobs` WHERE
                `x`='"
.$attack['x']."'
                AND `y`='"
.$attack['y']."'
                AND (
                (`x1`='"
.($attack['x1']+1)."' AND `y1`='".$attack['y1']."')
                OR (`x1`='"
.$attack['x1']."' AND `y1`='".($attack['y1']+1)."')
                OR (`x1`='"
.($attack['x1']+1)."' AND `y1`='".($attack['y1']+1)."')
                OR (`x1`='"
.($attack['x1']-1)."' AND `y1`='".$attack['y1']."')
                OR (`x1`='"
.$attack['x1']."' AND `y1`='".($attack['y1']-1)."')
                OR (`x1`='"
.($attack['x1']-1)."' AND `y1`='".($attack['y1']-1)."')
                OR (`x1`='"
.($attack['x1']-1)."' AND `y1`='".($attack['y1']+1)."')
                OR (`x1`='"
.($attack['x1']+1)."' AND `y1`='".($attack['y1']-1)."'))
                AND `battle`=''"
);
                while(
$alltargets=mysql_fetch_assoc($qat)){
                    if (
time()-$alltargets['last_death']>=$alltargets['death_time']){
                        
mysql_query("UPDATE `mobs` SET
                        `last_damag`='"
.time()."',
                        `battle`='"
.$battle."',
                        `hp`='"
.$alltargets['max_hp']."',
                        `battle_attack`='"
.$account['id']."'
                        WHERE
                        `id`='"
.$alltargets['id']."'");
                    }
                }
            }
            
header("Location: /battle.php?");
            exit;
        }
    }
    
$account['x1']=mysql_result(mysql_query("SELECT `x1` FROM `account` WHERE `id`='".$account['id']."'"),0);
    
$account['y1']=mysql_result(mysql_query("SELECT `y1` FROM `account` WHERE `id`='".$account['id']."'"),0);
    echo 
'<div class="title">';
echo 
$location['name'];
echo 
'</div>';
echo 
'<div class="border-top"></div>';
echo 
'<div class="help">';
echo 
'<center>';
if (
$account['set_loccompress']=='bad'){
    
$quality 70;
}elseif(
$account['set_loccompress']=='not_bad'){
    
$quality 80;
}elseif(
$account['set_loccompress']=='good'){
    
$quality 90;
}elseif(
$account['set_loccompress']=='splendid'){
    
$quality 100;
}
echo 
'<div style="background:url(lcompress.php?li='.$location['img'].'&q='.$quality.');width:200px;height:200px;">';
echo 
'<table width="100%" height="100%><tr height="18px">';
$x1=1;
$y1=1;
for(
$i=0;$i<100;$i++){
    if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x1`='".$x1."' AND `y1`='".$y1."' AND `x`='".$location['x']."' AND `y`='".$location['y']."'"),0)){
        
$sublocation=mysql_fetch_array(mysql_query("SELECT * FROM `sublocation` WHERE `x1`='".$x1."' AND `y1`='".$y1."' AND `x`='".$location['x']."' AND `y`='".$location['y']."'"));
        
$title=$sublocation['name'];
        
$class=NULL;
        
$style=NULL;
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `mobs` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"),0)){
            
$mob=mysql_fetch_array(mysql_query("SELECT * FROM `mobs` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"));
            
$title=$mob['name'];
            if (
time()-$mob['last_death']<$mob['death_time']){
                
$style="max-width:16px; max-height:16px; background:url(data/userlocdeath.png) no-repeat center;";
            }elseif(
$mob['agrored']==NULL){
                
$style="max-width:16px; max-height:16px; background:url(data/userlocyello.png) no-repeat center;";
            }else{
                
$style="max-width:16px; max-height:16px; background:url(data/userlocred.png) no-repeat center;";
            }
        }
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `account` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."' AND '360'>'".time()."'-`last_active`"),0)){
            
$usereloc=mysql_query("SELECT * FROM `account` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'  AND '360'>'".time()."'-`last_active`");
            
$title='';
            
$cntusr=0;
            while(
$userlocloc=mysql_fetch_assoc($usereloc)){
                if (
$account['id']!=$userlocloc){
                    if (
$cntusr>0){
                        
$title.='<br />'.$userlocloc['name'];
                    }else{
                        
$title.=$userlocloc['name'];
                    }
                    
$contusr++;
                }
            }
            
$style="max-width:16px; max-height:16px; background:url(data/userloc.png) no-repeat center;";
        }
        if (
mysql_result(mysql_query("SELECT COUNT(*) FROM `npc` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"),0)){
            
$npc=mysql_fetch_array(mysql_query("SELECT * FROM `npc` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$x1."' AND `y1`='".$y1."'"));
            
$title=$npc['name'];
            
$style="max-width:16px; max-height:16px; background:url(data/userlocblue.png) no-repeat center;";
        }
        if (
$account['x1']==$x1 && $account['y1']==$y1){
            
$title='Вы';
            
$style="max-width:16px; max-height:16px; background:url(data/userloc.png) no-repeat center;";
            
$class=$account['class'];
        }
        echo 
'<td width="16px" style="/*border:1px solid black;*/ padding:0px;margin:0px; '.$style.'" title="'.$title.'">';
        if (!isset(
$mob) && !isset($npc)){
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вправо
                //влево
                
if ($account['x1']+1==$x1 && $account['y1']==$y1)echo '<a href="?x1='.($account['x1']+1).'&y1='.$account['y1'].'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".($account['x1']-1)."' AND `y1`='".$account['y1']."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение влево
                //вправо
                
if ($account['x1']-1==$x1 && $account['y1']==$y1)echo '<a href="?x1='.($account['x1']-1).'&y1='.$account['y1'].'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$account['x1']."' AND `y1`='".($account['y1']+1)."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вниз
                //вниз
                
if ($account['y1']+1==$y1 && $account['x1']==$x1)echo '<a href="?x1='.$account['x1'].'&y1='.($account['y1']+1).'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".$account['x1']."' AND `y1`='".($account['y1']-1)."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вверх
                //вверх
                
if ($account['y1']-1==$y1 && $account['x1']==$x1)echo '<a href="?x1='.$account['x1'].'&y1='.($account['y1']-1).'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".($account['x1']+1)."' AND `y1`='".($account['y1']+1)."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вверх
                //вниз вправо
                
if ($account['y1']+1==$y1 && $account['x1']+1==$x1)echo '<a href="?x1='.($account['x1']+1).'&y1='.($account['y1']+1).'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".($account['x1']-1)."' AND `y1`='".($account['y1']+1)."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вверх
                //вниз влево
                
if ($account['y1']+1==$y1 && $account['x1']-1==$x1)echo '<a href="?x1='.($account['x1']-1).'&y1='.($account['y1']+1).'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".($account['x1']+1)."' AND `y1`='".($account['y1']-1)."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вверх
                //вверх вправо
                
if ($account['y1']-1==$y1 && $account['x1']+1==$x1)echo '<a href="?x1='.($account['x1']+1).'&y1='.($account['y1']-1).'"><img src="/data/lochrefuser.png"></a>';
            }
            if(
mysql_result(mysql_query("SELECT COUNT(*) FROM `sublocation` WHERE `x`='".$location['x']."' AND `y`='".$location['y']."' AND `x1`='".($account['x1']-1)."' AND `y1`='".($account['y1']-1)."'  AND (`cant_go`='0'  OR `cant_go`='')"),0)){//Перемещение вверх
                //вверх влево
                
if ($account['y1']-1==$y1 && $account['x1']-1==$x1)echo '<a href="?x1='.($account['x1']-1).'&y1='.($account['y1']-1).'"><img src="/data/lochrefuser.png"></a>';
            }
        }
        echo 
'</td>';
        
$x1++;
    }else{
        
//echo '<td width="16px" height="20px" style="border:1px solid red;margin:0px;padding:0px; padding:0px;margin:0px;" title="'.$x1.'">'.$y1.'</td>';
        
echo '<td width="16px" style="/*border:1px solid red;*/ padding:0px;margin:0px;" title="'.$location['name'].'"></td>';
        
$x1++;
    }
    if (
$i==9){
        
$y1=$y1+1;
        
$x1=1;
        echo 
'</tr><tr height="18px">';
    }elseif(
$i==19){
        
$y1=$y1+1;
        
$x1=1;
        echo 
'</tr><tr height="18px">';
    }elseif(
$i==29){
        echo 
'</tr><tr height="18px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==39){
        echo 
'</tr><tr height="18px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==49){
        echo 
'</tr><tr height="18px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==59){
        echo 
'</tr><tr height="18px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==69){
        echo 
'</tr><tr height="18px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==79){
        echo 
'</tr><tr height="18px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==89){
        echo 
'</tr><tr height="17px">';
        
$y1=$y1+1;
        
$x1=1;
    }elseif(
$i==100){
        echo 
'</tr>';
        
$y1=$y1+1;
        
$x1=1;
    }
    unset(
$mob);
    unset(
$npc);
}
echo 
'</table>';
echo 
'</div>';
echo 
'</center>';
echo 
'</div>';
 if (
mysql_num_rows(mysql_query("SELECT * FROM `mobs` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."'))
 AND `x`='"
.$location['x']."' AND `y`='".$location['y']."'
 "
)) OR mysql_num_rows(mysql_query("SELECT * FROM `npc` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."'))
 AND `x`='"
.$location['x']."' AND `y`='".$location['y']."'
 "
)) OR mysql_num_rows(mysql_query("SELECT * FROM `account` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
 OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
 OR (`x1`='"
.$account['x1']."' AND `y1`='".$account['y1']."'))
 AND `x`='"
.$location['x']."' AND `y`='".$location['y']."' AND '".time()."'-`last_active`<'360'
 "
))){
//НПЦ
$resn=mysql_query("SELECT * FROM `npc` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."'))
    AND `x`='"
.$location['x']."' AND `y`='".$location['y']."'
    "
);
    while(
$result=mysql_fetch_array($resn)){
        echo 
'<a class="link" href="?npc='.$result['id'].'"><table><td>
        <img src="/data/img/units/npc/'
.$result['icon'].'.jpg" width="24px" height="24px"></td><td>
        '
.$result['name'].'</td></table></a>';
        
//echo '<a href="?npc='.$result['id'].'">Поговорить</a>';
    
}
    
//echo '</div>';
 //Мобы
$resm=mysql_query("SELECT * FROM `mobs` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."'))
    AND `x`='"
.$location['x']."' AND `y`='".$location['y']."'
    "
);
    while(
$resultm=mysql_fetch_array($resm)){


        if (
time()-$resultm['last_death']<$resultm['death_time']){
                    echo 
'<div class="help">';
            echo 
'<table><tr><td><img src="/data/img/units/mobs/'.$resultm['icon'].'.jpg" width="24px" height="24px"></td><td>'.$resultm['name'].' <b>'.$resultm['lvl'].'</b> ур. - <b>Существо мертво</b></td></tr></table></div>';
        }else{
            echo 
'
        <a class="link" href="?attack='
.$resultm['id'].'"><table><tr><td><img src="/data/img/units/mobs/'.$resultm['icon'].'.jpg" width="24px" height="24px"></td>';
        echo 
'<td>'.$resultm['name'];
        echo 
' <b>'.$resultm['lvl'].'</b> ур. </td></tr></table></a> ';
        }
    }
//Пользователи
echo '<div class="help">Кто рядом: ';
$resusr=mysql_query("SELECT * FROM `account` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".$account['y1']."'))
    AND `x`='"
.$account['x']."' AND `y`='".$account['y']."'  AND '".time()."'-`last_active`<'360' AND `id`!='".$account['id']."'
    "
);
    
$cent=0;
    while(
$resultusr=mysql_fetch_array($resusr)){
        
$cent++;
        if (
$cent>1){
            echo 
', ';
        }
        if (
$account['id']!=$resultusr['id'] && time()-$resultusr['last_active']<360){
            echo 
'<a href="/char.php?id='.$resultusr['id'].'">'.$resultusr['name'].'</a>';
        }
        if (!
$resultusr['battle'] && !$resultusr['duel_battle']){
            echo 
' <a href="?duel='.$resultusr['id'].'">(Дуэль)</a>';
        }
        
    }
    
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `account` WHERE ((`x1`='".($account['x1']+1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".($account['y1']+1)."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']+1)."' AND `y1`='".($account['y1']-1)."')
    OR (`x1`='"
.($account['x1']-1)."' AND `y1`='".$account['y1']."')
    OR (`x1`='"
.$account['x1']."' AND `y1`='".$account['y1']."'))
    AND `x`='"
.$account['x']."' AND `y`='".$account['y']."'  AND '".time()."'-`last_active`<'360' AND `id`!='".$account['id']."'
    "
),0);
if (!
$ca){
    echo 
'никого нет';
}
echo 
'</div>';
}
}else{

header ("Location: /?"); 
exit;

}


down();

?>
Онлайн: 2
Реклама