function delete_house($user_id, $build_id = 0, $town = 0) { //Если $build_id=0 - удаляем все постройки из-за налогов и удаляем саму землю //Иначе удаляем конкретное $build_id здание из houses_users из-за ремонта //При удалении дома - из-за ремонта - остальные здания не удаляем. //возвращаем предметы из хранилищ в его инвентарь (кроме эликсиров) $weight = 0; // Если сломан основной дом, то уничтожаем все здания в городе if ($build_id >= 1 and $build_id <= 4) { $build_id = 0; } if ($build_id == 0) { $selitems = myquery("SELECT SUM(game_items_factsheet.weight) AS weight FROM game_items,game_items_factsheet WHERE game_items.priznak=4 AND game_items.item_id=game_items_factsheet.id AND game_items.user_id=" . $user_id . " AND game_items_factsheet.type<>13 AND (game_items.town=" . $town . " OR " . $town . "=0) GROUP BY game_items.user_id"); myquery("UPDATE game_items SET priznak=0 WHERE priznak=4 AND user_id=" . $user_id . " AND (game_items.town=" . $town . " OR " . $town . "=0) "); $weight = 0; if (mysql_num_rows($selitems)) { $weight += mysql_result($selitems, 0, 0); } } //возвращаем эликсиры из хранилищ в его инвентарь if ($build_id == 0 or $build_id >= 13 and $build_id <= 16) { $selitems = myquery("SELECT SUM(game_items_factsheet.weight) AS weight FROM game_items,game_items_factsheet WHERE game_items.priznak=4 AND game_items.item_id=game_items_factsheet.id AND game_items.user_id={$user_id} AND game_items_factsheet.type=13 AND (game_items.town=" . $town . " OR " . $town . "=0) GROUP BY game_items.user_id"); myquery("UPDATE game_items SET priznak=0 WHERE priznak=4 AND user_id={$user_id} AND (game_items.town=" . $town . " OR " . $town . "=0) "); $weight = 0; if (mysql_num_rows($selitems)) { $weight += mysql_result($selitems, 0, 0); } } //возвращаем ресурсы из хранилища if ($build_id == 0 or $build_id >= 9 and $build_id <= 12) { $hransel = myquery("SELECT crm.id, crm.col FROM craft_resource_market crm WHERE crm.user_id=" . $user_id . " AND crm.priznak=1 AND (crm.town=" . $town . " OR " . $town . "=0)"); $weight = 0; if ($hransel != false and mysql_num_rows($hransel) > 0) { while ($hran = mysql_fetch_array($hransel)) { $Res = new Res(0, 0, $user_id); $Res->take_house(0, $hran['id'], (int) $hran['col']); } } } //удаляем и снимаем коня if ($build_id == 0 or $build_id >= 6 and $build_id <= 8) { myquery("DELETE FROM game_users_horses WHERE user_id=" . $user_id . " AND used=0 AND (town=" . $town . " OR " . $town . "=0) "); } // Обновим инвентарь игрока if ($weight > 0) { myquery("UPDATE game_users SET CW=CW+" . $weight . " WHERE user_id=" . $user_id . ""); myquery("UPDATE game_users_archive SET CW=CW+" . $weight . " WHERE user_id=" . $user_id . ""); } // Удаляем дома/постройки игрока за задолженность if ($build_id == 0) { //Удаляем все постройки+дом myquery("DELETE FROM houses_market WHERE user_id=" . $user_id . " AND (town_id=" . $town . " OR " . $town . "=0)"); myquery("DELETE FROM houses_users WHERE user_id=" . $user_id . " AND (town_id=" . $town . " OR " . $town . "=0)"); if (mysql_num_rows(myquery("SELECT * FROM houses_users WHERE user_id=" . $user_id . "")) == 0) { myquery("DELETE FROM houses_nalog WHERE user_id=" . $user_id . ""); } } else { //Удаляем конкретное здание/постройку myquery("DELETE FROM houses_market WHERE user_id={$user_id} AND build_id={$build_id} AND (town_id=" . $town . " OR " . $town . "=0) "); myquery("DELETE FROM houses_users WHERE user_id={$user_id} AND build_id={$build_id} AND (town_id=" . $town . " OR " . $town . "=0) "); } //Вышлем игроку уведомление if ($build_id == 0) { $theme = 'Все Ваши постройки были уничтожены!'; $post = 'В связи с длительным отсутствием ремонта все Ваши постройки были уничтожены!'; } else { list($name) = mysql_fetch_array(myquery("SELECT name FROM houses_templates WHERE id = " . $build_id . " ")); $theme = 'Ваша постройка <b>' . $name . '</b> была уничтожена!'; $post = 'В связи с длительным отсутствием ремонта Ваша постройка <b>' . $name . '</b> была уничтожена!'; } myquery("INSERT INTO game_pm (komu, otkogo, theme, post, view, time, folder) VALUES ('" . $user_id . "', '0', '" . $theme . "', '" . $post . "','0','" . time() . "',1)"); }
//операции с хранилищем ресурсов $free = $templ['min_value'] - mysqlresult(myquery("SELECT SUM(craft_resource_market.col*craft_resource.weight) FROM craft_resource,craft_resource_market WHERE craft_resource_market.user_id={$user_id} AND craft_resource_market.priznak=1 AND craft_resource_market.town={$town} AND craft_resource_market.res_id=craft_resource.id"), 0, 0); if (isset($_GET['sel_hran'])) { if ($free > 0) { $selec = myquery("select craft_resource_user.id,craft_resource.img3 AS img,craft_resource.name from craft_resource,craft_resource_user where craft_resource_user.user_id={$user_id} and craft_resource_user.col>0 and craft_resource.id=craft_resource_user.res_id"); while ($row = mysql_fetch_array($selec)) { echo '<table border="0" cellpadding="1"><tr><td></td></tr></table><table border="1" cellpadding="0" style="border-collapse: collapse" width="98%" bordercolor="777777" bgcolor="223344"><tr><td width=70 align=center><a href=town.php?option=' . $option . '&hran=' . $row["id"] . '&part4&add=' . $build_id . '><img src="http://' . img_domain . '/item/resources/' . $row["img"] . '.gif" border="0"></a></td><td><a href=town.php?option=' . $option . '&hran=' . $row["id"] . '&part4&add=' . $build_id . '>' . $row["name"] . '</a></td></tr></table>'; } echo 'Нажми на рисунок, чтобы положить ресурс в ' . $templ['name']; } else { echo '<br />В здании "' . $templ['name'] . '" больше нет свободных мест!<br />'; } } elseif (isset($_GET['get'])) { if (isset($_GET['getnow']) and (int) $_GET['getnow'] > 0) { $Res = new Res(); $weight = $Res->take_house(0, $_GET['get'], (int) $_GET['getnow']); echo $Res->message . '<br><br>'; $free += $weight; $char['CC'] -= $weight; } else { $hransel = myquery("SELECT craft_resource_market.col,craft_resource.img3 AS img,craft_resource.name,craft_resource.weight,craft_resource.id AS res_id FROM craft_resource_market,craft_resource WHERE craft_resource_market.user_id={$user_id} AND craft_resource_market.town={$town} AND craft_resource_market.res_id=craft_resource.id AND craft_resource_market.id=" . $_GET['get'] . " AND craft_resource_market.priznak=1"); if ($hransel != false and mysql_num_rows($hransel) > 0) { $hran = mysql_fetch_array($hransel); echo '<center>Взять из хранилища <input size="5" type="text" id="hran_col" value="0"> ед из ' . $hran['col'] . ' ед. ресурса <img src="http://' . img_domain . '/item/resources/' . $hran["img"] . '.gif" border="0"></a> ' . $hran['name'] . '<br /><i>1 единица ресурса ' . $hran['name'] . ' весит ' . $hran['weight'] . ' кг.</i>'; echo '<br /><br /><input type="button" value="Взять ресурс из хранилища" onclick="location.replace(\'town.php?option=' . $option . '&part4&add=' . $build_id . '&get=' . $_GET['get'] . '&getnow=\'+document.getElementById(\'hran_col\').value+\'\')"><br/><br><br>'; } } } elseif (isset($_GET['hran'])) { if ($free > 0) { if (isset($_GET['hrannow']) and $_GET['hrannow'] > 0) { $it = (int) $_GET['hran'];