コード例 #1
0
ファイル: combat.php プロジェクト: themiddleearth/RPG.SU
function end_script_combat($name = 0)
{
    global $_SERVER;
    show_debug($name);
    mysql_close();
    if (function_exists("save_debug")) {
        save_debug();
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: themiddleearth/RPG.SU
	</table>
	</td>
	<td valign="bottom">    
		<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
			<tr> 
				<td>&nbsp;</td>
			</tr>
		</table>
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr> 
				<td background="' . $img . '/img/bot-back.gif">
				<div style="width:100%" align="center"><img src="' . $img . '/img/bot-mid.gif" width="352" height="70"></div>
				</td>
			</tr>
		</table>
	</td>
</tr>
</table>
<center>';
include "../lib/banners.php";
echo '
</center>
</body>

</html>';
if ($_SERVER['REMOTE_ADDR'] == debug_ip) {
    show_debug();
}
if (function_exists("save_debug")) {
    save_debug();
}
コード例 #3
0
 public function take($id = 0, $place_id, $kol = 1)
 {
     $check1 = $this->init_res_nonuser($id, $place_id);
     if ($check1 == 1) {
         $kol = min($kol, $this->res_nonuser['col']);
         //Даём ресурс игроку
         $check2 = $this->add_user(0, $this->char['user_id'], $kol, $this->res_nonuser['dead_time']);
         if ($check2 == 1) {
             //Забираем ресурс с карты
             $this->add_map(0, 0, -$kol);
         } elseif ($this->message_type == 1) {
             setLocation("act.php?errror=full_inv");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         }
     }
 }
コード例 #4
0
function attack_user($char, $player, $type, $turnir_type = 0)
{
    $id = $player['user_id'];
    $user_id = $char['user_id'];
    $l_type = $type;
    $map = mysql_fetch_array(myquery("SELECT * FROM game_maps WHERE id=" . $char['map_name'] . ""));
    if ($l_type != 8 and $l_type != 9) {
        if (check_attack($char, $player, $l_type, $map) != 1) {
            if (function_exists("save_debug")) {
                save_debug();
            }
            return 0;
        }
    }
    if (clans_war == 1 and $map['dolina'] == 1 and clans_war_type > 0) {
        $type = clans_war_type;
    }
    if (chaos_war == 1) {
        $type = 5;
    }
    // Проверка на то, что игрок не нападает на другого более 2-ух раз за последний час
    $kol_attacks = mysql_num_rows(myquery("SELECT count(*) as kol FROM game_combats_log WHERE user1_id = " . $user_id . " AND user2_id = " . $id . " AND time>=" . (time() - 60 * 60) . " HAVING kol>=2"));
    // Создаём бой
    $uid = create_combat($type, $char['map_name'], $char['map_xpos'], $char['map_ypos'], $turnir_type, $user_id, $id);
    $side_char = $char['user_id'];
    $side_player = $player['user_id'];
    switch ($type) {
        case 1:
            $nam = 14;
            break;
        case 2:
            $nam = 15;
            break;
        case 3:
            $nam = 16;
            break;
        case 4:
            $nam = 17;
            $side_char = $char['clan_id'];
            $side_player = $player['clan_id'];
            break;
        case 5:
            $nam = 18;
            break;
        case 6:
            $nam = 49;
            $side_char = $char['sklon'];
            $side_player = $player['sklon'];
            break;
        case 7:
            $nam = 48;
            $side_char = $char['race'];
            $side_player = $player['race'];
            break;
        case 8:
            $nam = 47;
            break;
        case 9:
            $nam = 46;
            break;
    }
    $skill = take_skills($char['user_id']);
    $skill1 = take_skills($player['user_id']);
    //Проверим нет ли на пострадавшем эффекта "Неуязвимости"
    $check_effect = myquery("SELECT * FROM game_obelisk_users WHERE user_id='" . $player['user_id'] . "' AND type=6 AND time_end>" . time() . " ");
    if ($turnir_type == 0 and $map['dolina'] != 1 and ($char['vsadnik'] < $player['vsadnik'] or mysql_num_rows($check_effect) > 0 or $kol_attacks > 0)) {
        $func1 = 2;
        $func2 = 1;
    } else {
        $func1 = 5;
        $func2 = 5;
        if ($type == 4) {
            myquery("INSERT INTO game_log (message,date,FROMm,ob) VALUES ('" . iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-weight:900;font-size:14px;color:red;font-family:Verdana,Tahoma,Arial,Helvetica,sans-serif\"> ВНИМАНИЕ! <img align=\"center\" src=\"http://" . img_domain . "/clan/" . $char['clan_id'] . ".gif\"> " . mysql_result(myquery("SELECT nazv FROM game_clans WHERE clan_id=" . $char['clan_id'] . ""), 0, 0) . " и <img align=\"center\" src=\"http://" . img_domain . "/clan/" . $player['clan_id'] . ".gif\"> " . mysql_result(myquery("SELECT nazv FROM game_clans WHERE clan_id=" . $player['clan_id'] . ""), 0, 0) . " начинают бой: " . $map['name'] . "(" . $char['map_xpos'] . "; " . $char['map_ypos'] . ") </span>'") . "," . time() . ",-1,1)");
        }
        //Если на игрока напали против его воли, то, при наличии соответствующего навыка, выдадим его эффект неуязвимости
        if ($type == 4 and $skill1['HIDE'] > 0 and mysql_num_rows($check_effect) == 0) {
            $time_hide = time() + $skill1['HIDE'] * 3 * 60;
            myquery("INSERT INTO game_obelisk_users (user_id,time_end,type) VALUES (" . $player['user_id'] . "," . $time_hide . ",6)");
        }
    }
    //Снимем с атакующего игрока эффект неуязвимости
    myquery("DELETE FROM game_obelisk_users WHERE user_id=" . $char['user_id'] . " AND type=6");
    $hod = 1;
    //Кидаем в бой игроков
    combat_insert($char, 0, $uid, $type, $side_char, $hod, 0, 0, 0, $map['k_exp'] / 100, $map['k_gp'] / 100, $skill, $func1, $nam, 1);
    combat_insert($player, 0, $uid, $type, $side_player, $hod, 0, 0, 0, $map['k_exp'] / 100, $map['k_gp'] / 100, $skill1, $func2, $nam, 1);
    //Отработаем действие навыка "Убийца" для 1-ого игрока
    if ($skill['SLAYER'] > 0) {
        $r = mt_rand(1, 100);
        if ($r <= $skill['SLAYER'] * 2 + 5) {
            $effect = $skill['SLAYER'] * 5;
            insert_fast_effect($char['user_id'], $player['user_id'], $uid, $hod, 42, $effect);
        }
    }
    if ($l_type != 8 and $l_type != 9) {
        $pismo = iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-style:italic;font-size:12px;color:gold;\">На тебя напал игрок <b>" . $char['name'] . "</b></span>");
        myquery("INSERT INTO game_log (`message`,`date`,`FROMm`,`too`,`ptype`) VALUES ('" . mysql_real_escape_string($pismo) . "'," . time() . ",-1,{$id},1)");
    } else {
        $pismo = iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-style:italic;font-size:12px;color:gold;\">Начинается турнирная дуэль с игроком: <b>" . $char['name'] . "</b></span>");
        myquery("INSERT INTO game_log (`message`,`date`,`FROMm`,`too`,`ptype`) VALUES ('" . mysql_real_escape_string($pismo) . "'," . time() . ",-1," . $player['user_id'] . ",1)");
        $pismo = iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-style:italic;font-size:12px;color:gold;\">Начинается турнирная дуэль с игроком: <b>" . $player['name'] . "</b></span>");
        myquery("INSERT INTO game_log (`message`,`date`,`FROMm`,`too`,`ptype`) VALUES ('" . mysql_real_escape_string($pismo) . "'," . time() . ",-1," . $char['user_id'] . ",1)");
    }
    if ($l_type != 8 and $l_type != 9) {
        save_stat($user_id, '', '', 16, '', '', '', $player['clan_id'], '', '', '');
    }
    setLocation("http://" . domain_name . "/combat.php");
    return '';
}
コード例 #5
0
ファイル: class_item.php プロジェクト: themiddleearth/RPG.SU
 public function take($id = 0, $count_item = 1)
 {
     global $_SESSION;
     global $user_time;
     //1. проверим находится ли данный предмет на одной гексе с игроком и чтобы у него priznak=2
     //2. меняем предмету user_id, устанавливаем priznak=0,map_name=0,map_xpos=0,map_ypos=0
     if ($id > 0) {
         $this->init_item($id);
     }
     if ($this->item['map_name'] == $this->char['map_name'] and $this->item['map_xpos'] == $this->char['map_xpos'] and $this->item['map_ypos'] == $this->char['map_ypos'] and $this->item['priznak'] == 2) {
         if ($this->fact['name'] == 'Зелье зарядки артефактов') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $rand = mt_rand(10, 20);
             $sel = myquery("SELECT game_items.id,game_items.item_id,game_items.count_item,game_items_factsheet.item_uselife FROM game_items,game_items_factsheet WHERE game_items.user_id=" . $this->char['user_id'] . " AND game_items.used=3 AND game_items.priznak=0 AND game_items.item_id=game_items_factsheet.id");
             if ($sel != false) {
                 list($id_art, $ident_art, $cur_zar, $max_zar) = mysql_fetch_array($sel);
                 $new_zar = min($max_zar, $cur_zar + $rand);
                 myquery("UPDATE game_items SET count_item={$new_zar} WHERE id={$id_art}");
                 $rand = $new_zar - $cur_zar;
             } else {
                 $rand = 0;
             }
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('зарядил', 'зарядила') . ' артефакт на ' . $rand . ' зарядов';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Сундук с сокровищами') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             myquery("UPDATE game_users SET GP=GP + " . $this->item['item_cost'] . " WHERE user_id=" . $this->char['user_id'] . "");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('нашел', 'нашла') . ' сундук с ' . $this->item['item_cost'] . ' монетами';
             setGP($this->char['user_id'], $this->item['item_cost'], 5);
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Кадка воды') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $stm = mt_rand(20, 90);
             if ($stm + $this->char['STM'] > $this->char['STM_MAX']) {
                 $stm = $this->char['STM_MAX'] - $this->char['STM'];
             }
             myquery("UPDATE game_users SET STM=STM + {$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('выпил', 'выпила') . ' воду и твоя энергия изменилась на ' . $stm . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Кусок мяса') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $stm = mt_rand(20, 90);
             if ($stm + $this->char['HP'] > $this->char['HP_MAX']) {
                 $stm = $this->char['HP_MAX'] - $this->char['HP'];
             }
             myquery("UPDATE game_users SET HP=HP + {$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('съел', 'съела') . ' мясо и твоя жизнь изменилась на ' . $stm . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Магический эликсир') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $stm = mt_rand(10, 70);
             if ($stm + $this->char['MP'] > $this->char['MP_MAX']) {
                 $stm = $this->char['MP_MAX'] - $this->char['MP'];
             }
             myquery("UPDATE game_users SET MP=MP + {$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('выпил', 'выпила') . ' магический эликсир и твоя мана изменилась на ' . $stm . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Бутылка с голубым зельем') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $hp = mt_rand(10, 50);
             $mp = mt_rand(20, 60);
             $stm = mt_rand(30, 70);
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $hp = -$hp;
                 if ($this->char['HP'] + $hp < 0) {
                     $hp = -$this->char['HP'];
                 }
             } else {
                 if ($hp + $this->char['HP'] > $this->char['HP_MAX']) {
                     $hp = $this->char['HP_MAX'] - $this->char['HP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $mp = -$mp;
                 if ($this->char['MP'] + $mp < 0) {
                     $mp = -$this->char['MP'];
                 }
             } else {
                 if ($mp + $this->char['MP'] > $this->char['MP_MAX']) {
                     $mp = $this->char['MP_MAX'] - $this->char['MP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $stm = -$stm;
                 if ($this->char['STM'] + $stm < 0) {
                     $stm = -$this->char['STM'];
                 }
             } else {
                 if ($stm + $this->char['STM'] > $this->char['STM_MAX']) {
                     $stm = $this->char['STM_MAX'] - $this->char['STM'];
                 }
             }
             myquery("UPDATE game_users SET HP=HP+{$hp},MP=MP+{$mp},STM=STM+{$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('выпил', 'выпила') . ' бутылку с голубым зельем и твоя мана изменилась на ' . $mp . ' единиц, твоя энергия изменилась на ' . $stm . ' единиц, твоя жизнь изменилась на ' . $hp . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Бутылка с бордовым зельем') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $hp = mt_rand(10, 40);
             $mp = mt_rand(20, 40);
             $stm = mt_rand(10, 40);
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $hp = -$hp;
                 if ($this->char['HP'] + $hp < 0) {
                     $hp = -$this->char['HP'];
                 }
             } else {
                 if ($hp + $this->char['HP'] > $this->char['HP_MAX']) {
                     $hp = $this->char['HP_MAX'] - $this->char['HP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $mp = -$mp;
                 if ($this->char['MP'] + $mp < 0) {
                     $mp = -$this->char['MP'];
                 }
             } else {
                 if ($mp + $this->char['MP'] > $this->char['MP_MAX']) {
                     $mp = $this->char['MP_MAX'] - $this->char['MP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $stm = -$stm;
                 if ($this->char['STM'] + $stm < 0) {
                     $stm = -$this->char['STM'];
                 }
             } else {
                 if ($stm + $this->char['STM'] > $this->char['STM_MAX']) {
                     $stm = $this->char['STM_MAX'] - $this->char['STM'];
                 }
             }
             myquery("UPDATE game_users SET HP=HP+{$hp},MP=MP+{$mp},STM=STM+{$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('выпил', 'выпила') . ' бутылку с бордовым зельем и твоя мана изменилась на ' . $mp . ' единиц, твоя энергия изменилась на ' . $stm . ' единиц, твоя жизнь изменилась на ' . $hp . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Неизвестная бутыль') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $hp = mt_rand(50, 90);
             $mp = mt_rand(50, 90);
             $stm = mt_rand(50, 90);
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $hp = -$hp;
                 if ($this->char['HP'] + $hp < 0) {
                     $hp = -$this->char['HP'];
                 }
             } else {
                 if ($hp + $this->char['HP'] > $this->char['HP_MAX']) {
                     $hp = $this->char['HP_MAX'] - $this->char['HP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $mp = -$mp;
                 if ($this->char['MP'] + $mp < 0) {
                     $mp = -$this->char['MP'];
                 }
             } else {
                 if ($mp + $this->char['MP'] > $this->char['MP_MAX']) {
                     $mp = $this->char['MP_MAX'] - $this->char['MP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $stm = -$stm;
                 if ($this->char['STM'] + $stm < 0) {
                     $stm = -$this->char['STM'];
                 }
             } else {
                 if ($stm + $this->char['STM'] > $this->char['STM_MAX']) {
                     $stm = $this->char['STM_MAX'] - $this->char['STM'];
                 }
             }
             myquery("UPDATE game_users SET HP=HP+{$hp},MP=MP+{$mp},STM=STM+{$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('выпил', 'выпила') . ' неизвестную бутыль и твоя мана изменилась на ' . $mp . ' единиц, твоя энергия изменилась на ' . $stm . ' единиц, твоя жизнь изменилась на ' . $hp . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Ампула с эликсиром') {
             myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
             $hp = mt_rand(40, 50);
             $mp = mt_rand(40, 50);
             $stm = mt_rand(40, 50);
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $hp = -$hp;
                 if ($this->char['HP'] + $hp < 0) {
                     $hp = -$this->char['HP'];
                 }
             } else {
                 if ($hp + $this->char['HP'] > $this->char['HP_MAX']) {
                     $hp = $this->char['HP_MAX'] - $this->char['HP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $mp = -$mp;
                 if ($this->char['MP'] + $mp < 0) {
                     $mp = -$this->char['MP'];
                 }
             } else {
                 if ($mp + $this->char['MP'] > $this->char['MP_MAX']) {
                     $mp = $this->char['MP_MAX'] - $this->char['MP'];
                 }
             }
             $r = mt_rand(1, 4);
             if ($r == 1) {
                 $stm = -$stm;
                 if ($this->char['STM'] + $stm < 0) {
                     $stm = -$this->char['STM'];
                 }
             } else {
                 if ($stm + $this->char['STM'] > $this->char['STM_MAX']) {
                     $stm = $this->char['STM_MAX'] - $this->char['STM'];
                 }
             }
             myquery("UPDATE game_users SET HP=HP+{$hp},MP=MP+{$mp},STM=STM+{$stm} WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('выпил', 'выпила') . ' ампулу с эликсиром и твоя мана изменилась на ' . $mp . ' единиц, твоя энергия изменилась на ' . $stm . ' единиц, твое здоровье изменилось на ' . $hp . ' единиц';
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['name'] == 'Сундук ключника') {
             //myquery("DELETE FROM game_items WHERE id=".$this->item['id']."");
             //проверяем наличие в инвентаре ключа от сундука
             $check = myquery("SELECT id FROM game_items WHERE item_id=" . item_id_key_constructor . " AND user_id=" . $this->char['user_id'] . " AND priznak=0 LIMIT 1");
             if (!mysql_num_rows($check)) {
                 $_SESSION['getsunduk'] = 'Для того, чтобы открыть <b>Сундук ключника</b>, надо иметь в инвентаре <b>Ключ от сундука ключника</b>!';
             } else {
                 //удаляем ключ
                 list($id_key) = mysql_fetch_array($check);
                 $ItemDel = new Item($id_key);
                 $ItemDel->admindelete();
                 //перемещаем сундук на новое место
                 $sel = myquery("SELECT xpos,ypos FROM game_maze WHERE map_name=" . $this->item['map_name'] . " AND (move_up+move_right+move_down+move_left>=2)");
                 $all = mysql_num_rows($sel);
                 $r = mt_rand(0, $all - 1);
                 mysql_data_seek($sel, $r);
                 $pos = mysql_fetch_assoc($sel);
                 myquery("UPDATE game_items SET map_xpos=" . $pos['xpos'] . ",map_ypos=" . $pos['ypos'] . " WHERE id=" . $this->item['id'] . "");
                 $item_name = "Ничего";
                 if ($this->char['map_name'] == 691 or $this->char['map_name'] == 692 or $this->char['map_name'] == 804) {
                     if ($this->char['map_name'] == 691) {
                         $drop = array(569, 570, 571, 572, 573, 574, 575, 320, 322, 321);
                     }
                     if ($this->char['map_name'] == 692) {
                         $drop = array(576, 577, 578, 579, 580, 581, 582, 321, 358, 322);
                     }
                     if ($this->char['map_name'] == 804) {
                         $drop = array(576, 577, 578, 579, 580, 581, 582, 321, 358, 322);
                     }
                     mt_srand(make_seed());
                     $ran = mt_rand(0, 9);
                     $item_id = $drop[$ran];
                     $ar = $this->add_user($item_id, $this->char['user_id'], 1);
                     if ($ar[0] == 0) {
                         $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук ключника, но в твоем инвентаре не хватает места для находок, и сундук исчезает!';
                     } else {
                         $item_name = mysqlresult(myquery("SELECT name FROM game_items_factsheet WHERE id={$item_id}"), 0, 0);
                         $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук ключника и ' . echo_sex('нашел', 'нашла') . ' в нем <b>' . $item_name . '</b>';
                     }
                 }
             }
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } elseif ($this->fact['id'] == item_id_sunduk) {
             //myquery("DELETE FROM game_items WHERE id=".$this->item['id']."");
             //проверяем наличие в инвентаре ключа от сундука
             $check = myquery("SELECT id FROM game_items WHERE item_id=" . item_id_old_key . " AND user_id=" . $this->char['user_id'] . " AND priznak=0 LIMIT 1");
             if (!mysql_num_rows($check)) {
                 $_SESSION['getsunduk'] = 'Для того, чтобы открыть <b>Сундук</b>, надо иметь в инвентаре <b><a href=\'info/?item=' . item_id_old_key . '\' target=_blank>Старый ключ</a></b>!';
             } else {
                 //удаляем ключ
                 list($id_key) = mysql_fetch_array($check);
                 $ItemDel = new Item($id_key);
                 $ItemDel->admindelete();
                 //удаляем сундук
                 myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
                 $item_name = "Ничего";
                 if ($this->char['map_name'] == id_map_tuman) {
                     $chance = mt_rand(0, 100);
                     $item_id = 0;
                     $id_svitok = 0;
                     $char = $this->char;
                     if ($char['map_xpos'] == 7 and $char['map_ypos'] == 0) {
                         $id_svitok = item_id_svitok_light_usil;
                         $item_name = "Свиток легкого усиления";
                     } elseif ($char['map_xpos'] == 0 and $char['map_ypos'] == 1) {
                         $id_svitok = item_id_svitok_light_usil;
                         $item_name = "Свиток легкого усиления";
                     } elseif ($char['map_xpos'] == 7 and $char['map_ypos'] == 2) {
                         $id_svitok = item_id_svitok_medium_usil;
                         $item_name = "Свиток среднего усиления";
                     } elseif ($char['map_xpos'] == 0 and $char['map_ypos'] == 3) {
                         $id_svitok = item_id_svitok_medium_usil;
                         $item_name = "Свиток среднего усиления";
                     } elseif ($char['map_xpos'] == 7 and $char['map_ypos'] == 4) {
                         $id_svitok = item_id_svitok_hard_usil;
                         $item_name = "Свиток большого усиления";
                     } elseif ($char['map_xpos'] == 0 and $char['map_ypos'] == 5) {
                         $id_svitok = item_id_svitok_hard_usil;
                         $item_name = "Свиток большого усиления";
                     } elseif ($char['map_xpos'] == 7 and $char['map_ypos'] == 6) {
                         $id_svitok = item_id_svitok_absolut_usil;
                         $item_name = "Свиток абсолютного усиления";
                     } elseif ($char['map_xpos'] == 0 and $char['map_ypos'] == 7) {
                         $id_svitok = item_id_svitok_absolut_usil;
                         $item_name = "Свиток абсолютного усиления";
                     }
                     if ($chance <= 50) {
                         $item_id = $id_svitok;
                     } elseif ($chance <= 75) {
                         $user_id = $char['user_id'];
                         $ress = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id=" . id_resource_saphire . ""));
                         $kol = 1;
                         $weight = $kol * $ress['weight'];
                         $prov = mysqlresult(myquery("SELECT count(*) FROM game_wm WHERE user_id={$user_id} AND type=1"), 0, 0);
                         if ($char['CW'] + $weight <= $char['CC'] or $prov > 0) {
                             $delay = $user_time + $weight;
                             $UPDATE_users = myquery("UPDATE game_users SET CW=(CW + {$weight}) WHERE user_id={$user_id} LIMIT 1");
                             set_delay_info($user_id, $delay, 7);
                             myquery("INSERT INTO craft_resource_user (user_id,res_id,col) VALUES ({$user_id}," . id_resource_saphire . ",1) ON DUPLICATE KEY UPDATE col=col+1");
                             $item_name = "Сапфир";
                             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук и ' . echo_sex('нашел', 'нашла') . ' в нем <b>' . $item_name . '</b>';
                         } else {
                             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук, но в твоем инвентаре не хватает места для находок, и сундук исчезает!';
                         }
                     } else {
                         $user_id = $char['user_id'];
                         list($amber, $wei) = mysql_fetch_array(myquery("SELECT id, weight FROM craft_resource WHERE name='Янтарь'"));
                         if (isset($amber) and $char['CW'] + $wei > $char['CC']) {
                             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук, но в твоем инвентаре не хватает места для находок, и сундук исчезает!';
                         } elseif (isset($amber)) {
                             myquery("INSERT INTO craft_resource_user (user_id,res_id,col) VALUES ({$user_id},{$amber},1) ON DUPLICATE KEY UPDATE col=col+1");
                             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук и ' . echo_sex('нашел', 'нашла') . ' в нем <b>Янтарь</b>';
                             myquery("UPDATE game_users Set CW=CW+{$wei} WHERE user_id={$user_id}");
                         }
                         /*$id_svitok = item_id_svitok_light_usil;
                           $item_name = "Свиток легкого усиления";*/
                     }
                     if ($item_id > 0) {
                         $ar = $this->add_user($item_id, $this->char['user_id'], 1);
                         if ($ar[0] == 0) {
                             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук, но в твоем инвентаре не хватает места для находок, и сундук исчезает!';
                         } else {
                             $item_name = mysqlresult(myquery("SELECT name FROM game_items_factsheet WHERE id={$item_id}"), 0, 0);
                             $_SESSION['getsunduk'] = 'Ты ' . echo_sex('открыл', 'открыла') . ' сундук и ' . echo_sex('нашел', 'нашла') . ' в нем <b>' . $item_name . '</b>';
                         }
                     }
                     if ($char['map_xpos'] == 0 and $char['map_ypos'] == 7) {
                         myquery("UPDATE game_users_map SET map_name = 18, map_xpos=26, map_ypos=21 WHERE user_id = " . $char['user_id'] . " ");
                     }
                 }
             }
             setLocation("act.php?getsunduk");
             if (function_exists("save_debug")) {
                 save_debug();
             }
             exit;
         } else {
             if ($this->fact['personal'] == 1) {
                 $personal = $this->char['user_id'];
             } else {
                 $personal = $this->item['personal'];
             }
             if ($this->fact['clan_id'] > 0 and $this->fact['clan_id'] != $this->char['clan_id']) {
                 setLocation("act.php?errror=wrong_clan");
                 if (function_exists("save_debug")) {
                     save_debug();
                 }
                 exit;
             } else {
                 if ($count_item <= $this->item['count_item']) {
                     $prov = mysql_result(myquery("SELECT count(*) FROM game_wm WHERE user_id=" . $this->char['user_id'] . " AND type=1"), 0, 0);
                     if ($this->char['CW'] + $this->fact['weight'] * $count_item <= $this->char['CC'] or $prov > 0) {
                         $kol_inv = @mysql_result(@myquery("SELECT SUM(`count_item`) FROM game_items WHERE user_id=" . $this->char['user_id'] . " AND item_id=" . $this->fact['id'] . " AND priznak=0"), 0, 0);
                         if ($this->fact['kol_per_user'] == 0 || $kol_inv + $count_item <= $this->fact['kol_per_user']) {
                             $ref_id = 1;
                             if ($this->counted_item()) {
                                 $ref_id = 0;
                                 $check = myquery("SELECT id FROM game_items WHERE user_id=" . $this->char['user_id'] . " AND priznak=0 AND used=0 AND item_id=" . $this->fact['id'] . "");
                                 if (mysql_num_rows($check) == 0) {
                                     if ($count_item == $this->item['count_item']) {
                                         $update_items = myquery("UPDATE game_items SET user_id=" . $this->char['user_id'] . ", ref_id=0, map_name=0, map_xpos=0, map_ypos=0, priznak=0, personal = " . $personal . " WHERE id=" . $this->item['id'] . "");
                                     } else {
                                         $update_items = myquery("INSERT INTO game_items (user_id,item_id,item_uselife,item_cost,item_for_quest,item_uselife_max,count_item,dead_time, personal) \n\t\t\t\t\t\t\t\t\t\t\tVALUES (" . $this->char['user_id'] . ",'" . $this->item['item_id'] . "','" . $this->item['item_uselife'] . "','" . $this->item['item_cost'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $this->item['item_for_quest'] . "','" . $this->item['item_uselife_max'] . "','" . $count_item . "'," . $this->item['dead_time'] . ", " . $personal . ")");
                                         myquery("UPDATE game_items SET count_item=count_item-" . $count_item . " WHERE id=" . $this->item['id'] . "");
                                     }
                                 } else {
                                     $update_items = myquery("UPDATE game_items SET count_item=count_item+" . $count_item . " WHERE user_id=" . $this->char['user_id'] . " AND priznak=0 AND item_id=" . $this->fact['id'] . " AND used=0");
                                     if ($count_item == $this->item['count_item']) {
                                         myquery("DELETE FROM game_items WHERE id=" . $this->item['id'] . "");
                                     } else {
                                         myquery("UPDATE game_items SET count_item=count_item-" . $count_item . " WHERE id=" . $this->item['id'] . "");
                                     }
                                 }
                             } else {
                                 $update_items = myquery("UPDATE game_items SET user_id=" . $this->char['user_id'] . ", ref_id='" . $ref_id . "', map_name=0, map_xpos=0, map_ypos=0,priznak=0, personal = " . $personal . " WHERE id=" . $this->item['id'] . "");
                             }
                             //$delay = $user_time + $this->fact['weight']; //Убираем ненужную задержку
                             $update_users = myquery("UPDATE game_users SET CW=CW + " . $this->fact['weight'] * $count_item . " WHERE user_id=" . $this->char['user_id'] . " LIMIT 1");
                             //set_delay_id($this->char['user_id'],$delay);
                         } else {
                             setLocation("act.php?errror=max_inv");
                             if (function_exists("save_debug")) {
                                 save_debug();
                             }
                             exit;
                         }
                     } else {
                         setLocation("act.php?errror=full_inv");
                         if (function_exists("save_debug")) {
                             save_debug();
                         }
                         exit;
                     }
                 }
             }
         }
     }
 }