function add_resource($id_resource) { global $user_id, $char, $_SESSION; if ($id_resource > 0) { $res = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id={$id_resource}")); $Res = new Res($res); $check = $Res->add_user(0, $user_id); if ($check == 1) { setCraftTimes($user_id, 6, 1, 1); echo 'Ты добыл: ' . $res['name']; myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$id_resource}, 0, 1, " . time() . ", {$user_id}, 'z')"); if (isset($_SESSION['cur_get_mining'])) { $dob = explode('###', $_SESSION['cur_get_mining']); $find = 0; for ($i = 0; $i < sizeof($dob); $i++) { $cur_dob = explode("&&&", $dob[$i]); if ($cur_dob[0] == $res['name']) { $find = 1; $col = (int) $cur_dob[1] + 1; $dob[$i] = $res['name'] . '&&&' . $col; } } if ($find == 0) { $dob[] = $res['name'] . '&&&1'; } $_SESSION['cur_get_mining'] = implode("###", $dob); } else { $str = $res['name'] . '&&&1'; $_SESSION['cur_get_mining'] = $str; } } else { echo 'У Вас недостаточно свободного места в инвентаре!'; } } }
public function drop_loot($user_id) { if ($this->error == 1) { return; } if ($this->npc['dropable'] == 1) { $seldrop = myquery("SELECT * FROM game_npc_drop WHERE npc_id=" . $this->templ['npc_id'] . ";"); if ($seldrop != false and mysql_num_rows($seldrop)) { $sum_chance = 0; $massiv = array(0); $m_last = 1; $mes = ""; $lcm = array(); $str = ""; $r = 0; $no_loot = 0; //Обработаем профессию "Охотник" if ($this->templ['npc_id'] == npc_id_olen) { if (checkCraftTrain($user_id, 8)) { $r = $r + 2 * getCraftLevel($user_id, 8); } else { $no_loot = 1; } } while ($chance = mysql_fetch_array($seldrop)) { $lcm[] = $chance['random_max']; } mysql_data_seek($seldrop, 0); $lcm = lcm_arr($lcm); while ($chance = mysql_fetch_array($seldrop)) { $this_chance = ($chance['random'] + $r) * $lcm / gcd($lcm, $chance['random_max']); $massiv = array_merge($massiv, array_fill($m_last, $this_chance, $chance)); $m_last += $this_chance; } if ($m_last < $lcm + 1) { $massiv = array_merge($massiv, array_fill($m_last, $lcm + 1 - $m_last, array('items_id' => 0))); } $drop = $massiv[mt_rand(1, $lcm)]; if ($drop['items_id'] != 0 and $no_loot == 0) { $it_user_id = 0; $priznak = 2; $kol_predmetov = mt_rand($drop['mincount'], $drop['maxcount']); $map_name = 0; $map_xpos = 0; $map_ypos = 0; for ($cikl = 1; $cikl <= $kol_predmetov; $cikl++) { $add_result = array(0); if ($drop['kuda'] == 1) { $it_user_id = $user_id; $priznak = 0; //проверим вес if ($drop['drop_type'] == 1) { $item = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE id=" . $drop['items_id'] . "")); } elseif ($drop['drop_type'] == 2) { $item = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id=" . $drop['items_id'] . "")); } list($CW, $CC) = mysql_fetch_array(myquery("SELECT CW,CC FROM view_active_users WHERE user_id={$it_user_id}")); $prov = mysqlresult(myquery("SELECT COUNT(*) FROM game_wm WHERE user_id={$it_user_id} AND type=1"), 0, 0); if ($CC - $CW < $item['weight'] and $prov == 0) { //инвентарь заполнен. На землю его! $it_user_id = 0; $priznak = 2; list($map_name, $map_xpos, $map_ypos) = mysql_fetch_array(myquery("SELECT map_name,map_xpos,map_ypos FROM game_users_map WHERE user_id={$it_user_id}")); $drop['kuda'] = 0; } } //если предмет if ($drop['drop_type'] == 1) { if ($priznak == 0) { $Item = new Item(); $add_result = $Item->add_user($drop['items_id'], $it_user_id, 0, 0, 1); // не получилось добавить один - не выйдет и остальные. if ($add_result[0] == 0) { break; } } else { if (!isset($item)) { $item = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE id=" . $drop['items_id'] . "")); } myquery("INSERT INTO game_items (user_id,item_id,priznak,ref_id,item_uselife,item_uselife_max,item_cost,map_name,map_xpos,map_ypos) VALUES ('{$it_user_id}','" . $drop['items_id'] . "','{$priznak}',0,'" . $item['item_uselife'] . "','" . $item['item_uselife_max'] . "','" . $item['item_cost'] . "','{$map_name}','{$map_xpos}','{$map_ypos}')"); } } elseif ($drop['drop_type'] == 2) { if ($drop['kuda'] == 1) { $Res = new Res($item, 0); $Res->add_user(0, $it_user_id, 1); if ($this->templ['npc_id'] == npc_id_olen) { myquery("INSERT INTO craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, " . $drop['items_id'] . ", 0, 1, " . time() . ", {$it_user_id}, 'z')"); setCraftTimes($it_user_id, 8, 1, 1); add_exp_for_craft($it_user_id, 8); } } elseif ($drop['kuda'] == 0) { $Res = new Res(0, $drop['items_id']); $Res->add_map(0, 0, 1, 0, $map_name, $map_xpos, $map_ypos); myquery("INSERT INTO craft_resource_market (user_id,town,col,price,res_id,opis,map_name,map_xpos,map_ypos) VALUES (0,0,1,0," . $drop['items_id'] . ",'','" . $map_name . "','" . $map_xpos . "','" . $map_ypos . "')"); } } if ($it_user_id > 0) { if ($drop['drop_type'] == 1) { $mes = '<font color=\\"#eeeeee\\">После убийства монстра ты ' . echo_sex('увидел', 'увидела') . ' оставшийся от него предмет: <b>' . $item['name'] . '</b>.Ты быстро ' . echo_sex('подобрал', 'подобрала') . ' выпавший предмет и ' . echo_sex('положил', 'положила') . ' его в свой инвентарь!</font>'; } elseif ($drop['drop_type'] == 2) { $mes = '<font color=\\"#eeeeee\\">После убийства монстра ты ' . echo_sex('заметил', 'заметила') . ', как он выронил из рук: <b>' . $item['name'] . '<b/>. Не мешкая ты быстро ' . echo_sex('подобрал', 'подобрала') . ' выпавший ресурс и ' . echo_sex('положил', 'положила') . ' его в свой инвентарь!</font>'; } $result = myquery("INSERT game_battles SET attacker_id=" . $user_id . ", target_id=0, map_name=" . $map_name . ", map_xpos=" . $map_xpos . ", map_ypos=" . $map_ypos . ", contents='" . $mes . "', post_time=" . time() . ""); } } } } } }
case $id_resource_copper_ore: $res_id_bullion = $id_resource_copper_bullion; break; case $id_resource_silver_nugget: $res_id_bullion = $id_resource_silver_bullion; break; case $id_resource_mithril_ore: $res_id_bullion = $id_resource_mithril_bullion; break; case $id_resource_gold_nugget: $res_id_bullion = $id_resource_gold_bullion; break; } $res_in = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id='" . $res_id_bullion . "' ")); $Res = new Res($res_in); $check = $Res->add_user(0, $user_id); if ($check == 1) { myquery("UPDATE game_items SET item_uselife=item_uselife-" . mt_rand(400, 600) / 100 . " WHERE user_id={$user_id} AND used=21 AND priznak=0"); list($id_item, $cur_uselife) = mysql_fetch_array(myquery("SELECT id,item_uselife FROM game_items WHERE priznak=0 AND user_id={$user_id} AND used=21")); if ($cur_uselife <= 0) { $Item = new Item($id_item); $Item->down(); } $mes = 'Получен ресурс: <i>' . $res_in['name'] . '</i> в количестве 1 ед.'; setCraftTimes($user_id, 10, 3, 1); myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$res_id_bullion}, 0, 1, " . time() . ", {$user_id}, 'z')"); } else { $mes = 'Неудачная попытка работы на плавильне. Проверь, хватает ли у тебя места для новых ресурсов в инвентаре!'; } myquery("DELETE FROM craft_build_founder WHERE user_id={$user_id}"); } else {
} } if ($check == 0) { echo "<span style=\"font-family:Tahoma,Verdana,helvetica;font-size:11px;color:#80FF80;\">{$build['name']} - тебе не удалось собрать этот ресурс</span>"; myquery("INSERT INTO craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) VALUES ({$build_id}, '0', '" . $b[0] . "', '0', '0', " . time() . ", {$user_id}, 'n')"); } echo '<br>'; } else { echo 'Владелец не смог с тобой расплатиться ресурсом: ' . $build['name'] . '!<br>'; } } echo '</b>'; //выплата владельцу $select1 = myquery("select * from craft_build where id={$build_type}"); $re = mysql_fetch_array($select1); $dohod1 = $re['res_dob']; $aa = explode("|", $dohod1); for ($i = 0; $i < count($aa); $i++) { $bb = explode("-", $aa[$i]); if (sizeof($bb) != 2) { continue; } $select2 = myquery("select * from craft_resource where id={$bb['0']}"); $build = mysql_fetch_array($select2); $Res = new Res($build); $check = $Res->add_user(0, $build_vladel); if ($check == 1 and $admin_build != 1) { myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values ({$build_id}, '', {$bb['0']}, {$bb['1']}, '', " . time() . ", {$build_vladel}, 'p')"); } } }
for ($i = 0; $i < $ress_num; $i++) { //для каждого реса $rid_index = 'rid' . $i; $col_index = 'col' . $i; $res_id = (int) $_POST[$rid_index]; if (!is_numeric($_POST[$col_index])) { $res_col = 0; } else { $res_col = max(0, $_POST[$col_index]); } if ($res_col > 0) { $res_need = mysql_result(myquery("SELECT res_num FROM dungeon_users_progress WHERE user_id=" . $user_id . " AND quest_id = " . $id . " AND res_id=" . $res_id . ""), 0, 0); $res_col = min($res_need, $res_col); $res_result = $res_need - $res_col; $Res = new Res(0, $res_id); $check = $Res->add_user(0, $user_id, -$res_col); if ($check == 1) { myquery("UPDATE dungeon_users_progress SET res_num=" . $res_result . " WHERE user_id=" . $user_id . " AND res_id =" . $res_id . " AND quest_id=" . $id . " "); $check_res = 1; } else { echo $Res->message; } } } //проверим, не выполнен ли квест echo '<table cellpadding="0" cellspacing="0" width="80%" border="0"><tr><td><p align=justify><br><center>'; $done_check = myquery("SELECT max(res_num) FROM dungeon_users_progress WHERE user_id=" . $user_id . " and quest_id = " . $id . " "); list($res_num) = mysql_fetch_array($done_check); $done = 1; if ($res_num > 0) { $done = 0;
} if ($result['out_id'] > 0) { //Выдаём игроку предметы $check = myquery("SELECT item_id, kol*'" . $result['out_kol'] . "' as kol FROM game_exchange_groups WHERE group_id = '" . $result['out_id'] . "' and item_type = 0"); if (mysql_num_rows($check) > 0) { while ($item = mysql_fetch_array($check)) { $Item = new Item(); $Item->add_user($item['item_id'], $char['user_id'], 0, 0, 0, $item['kol']); } } //Выдаём игроку ресурсы $check = myquery("SELECT item_id, kol*'" . $result['out_kol'] . "' as kol FROM game_exchange_groups WHERE group_id = '" . $result['out_id'] . "' and item_type = 1"); if (mysql_num_rows($check) > 0) { while ($item = mysql_fetch_array($check)) { $Res = new Res(0, $item['item_id']); $Res->add_user(0, $char['user_id'], $item['kol']); } } } //Выдаём игроку деньги if ($result['out_gp'] > 0) { save_gp($char['user_id'], $result['out_gp'], 110, 1); } echo '<b>Обмен успешно произведён!<b/><br>'; //Занесём в лог использование шатра myquery("INSERT INTO game_exchange_log (user_id, exchange_id) VALUES ('" . $user_id . "', '" . $result['id'] . "') ON DUPLICATE KEY UPDATE times=times+1 "); } echo '<br><br>'; } else { echo '<b>К сожалению, выбранного предолжения не существует!</b><br><br>'; }
$res_id_out = $id_resource_doska; break; default: exit; break; } //Забираем расходник $res_out = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id={$res_id_out}")); $Res = new Res($res_out); $Res->add_user(0, $user_id, -1); $mes = 'Израсходован ресурс: <i>' . $res_out['name'] . '</i> в количестве 1 ед. <br/>'; myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$res_id_out}, 0, -1, " . time() . ", {$user_id}, 'z')"); $char['CW'] = $char['CW'] - $res_out['weight']; $res_in = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id={$res_id_in}")); $Res1 = new Res($res_in); $check = $Res1->add_user(0, $user_id, $kol_res_in); if ($check == 1) { add_exp_for_craft($user_id, 7); myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$res_id_in}, 0, 1, " . time() . ", {$user_id}, 'z')"); setCraftTimes($user_id, 7, 1, 1); $mes .= 'Получен ресурс: <i>' . $res_in['name'] . '</i> в количестве ' . $kol_res_in . ' ед.'; } else { $mes .= '<b>У Вас недостаточно свободного места в инвентаре!</b>'; } //Поломаем предмет mt_srand(make_seed()); myquery("UPDATE game_items SET item_uselife=item_uselife-" . mt_rand(100, 250) / 100 . " WHERE user_id={$user_id} AND used=21 AND priznak=0"); list($id, $uselife) = mysql_fetch_array(myquery("SELECT id,item_uselife FROM game_items WHERE user_id={$user_id} AND used=21 AND priznak=0")); if ($uselife <= 0) { $Item = new Item($id); $Item->down();
if ($kol_doska > 0 and $need['doska'] > 0) { $put_now_doska = min($kol_doska, $need['doska']); $put_doska += $put_now_doska; $kol_doska -= $put_now_doska; } if ($put_now_blok > 0 or $put_now_doska > 0) { myquery("UPDATE houses_users SET stone_repair = stone_repair - " . $put_now_blok . ", doska_repair = doska_repair - " . $put_now_doska . " WHERE id = " . $need['id'] . ""); } } if ($put_blok > 0) { $Res = new Res(0, $id_resource_blok); $Res->add_user(0, $user_id, -$put_blok); } if ($put_doska > 0) { $Res = new Res(0, $id_resource_doska); $Res->add_user(0, $user_id, -$put_doska); } $mes = '<h3><font color="yellow"> Ремонт произведён!<br> Требовалось для ремонта: доска - ' . $need_doska . ' шт., камень - ' . $need_blok . ' шт.<br> Вложено в ремонт: доска - ' . $put_doska . ' шт., камень - ' . $put_blok . ' шт.<br> </h3></font>'; echo '<b>' . $mes . '</b>'; } if ($buildnowhouse == 0) { echo '<strong>Ты находишься в своих землевладениях.<br />'; $im_square = (int) mysqlresult(myquery("SELECT square FROM houses_users WHERE town_id={$town} AND user_id={$user_id} AND type=1"), 0, 0); // кол-во общей земли у игрока всего $im_square_sell = (int) mysqlresult(myquery("SELECT SUM(sotka) FROM houses_market WHERE town_id={$town} AND user_id={$user_id}"), 0, 0); // кол-во земли игрока на вторичном рынке $im_square_houses = (int) mysqlresult(myquery("SELECT SUM(houses_templates.square) FROM houses_users,houses_templates WHERE houses_users.town_id={$town} AND houses_users.user_id={$user_id} AND houses_users.build_id=houses_templates.id AND houses_users.type>1"), 0, 0);
} if (!isset($name) or !isset($type) or $name == '') { $name = 'Уголь'; $type = 'res'; } //Выдача приза if ($type == 'res') { $check_res = myquery("Select * From craft_resource Where name like '{$name}'"); if (mysql_num_rows($check_res) == 0) { $no_prize = 1; } else { $ress = mysql_fetch_array($check_res); $id = $ress['id']; $prize_type = 0; $Res = new Res($ress, 0); $Res->add_user(0, $user_id); } } elseif ($type == 'item') { list($id) = mysql_fetch_array(myquery("Select id From game_items_factsheet Where name like '{$name}'")); if (!isset($id) or $id == '') { $no_prize = 1; } else { $Item = new Item(); $ar = $Item->add_user($id, $user_id); $prize_type = 1; } } if (isset($no_prize) and $no_prize == 1) { echo '<center><font face=verdana color=ff0000 size=2>К сожалению, приз ' . $name . ' не найден!</font><meta http-equiv="refresh" content="4;url=town.php?option=' . $option . '"><br />'; } else { myquery("Update game_users Set GP=GP-'" . $cost . "' Where user_id='" . $user_id . "'");
<?php if (function_exists("start_debug")) { start_debug(); } if ($adm['resource'] >= 1) { echo '<center>'; //Добавление ресурсов игроку if (isset($_GET['user'])) { if (isset($_POST['add_res']) and isset($_POST['name']) and isset($_POST['kol']) and is_numeric($_POST['kol'])) { list($id) = mysql_fetch_array(myquery("SELECT user_id From game_users Where name='" . $_POST['name'] . "' UNION SELECT user_id From game_users_archive Where name='" . $_POST['name'] . "'")); $Res = new Res(0, $_POST['res_id']); $Res->add_user(0, $id, $_POST['kol'], 0, 1); $da = getdate(); $log = myquery("INSERT INTO game_log_adm (adm,dei,cur_time,day,month,year) \n\t\t\t VALUES (\n\t\t\t '" . $char['name'] . "',\n\t\t\t 'Добавил <b>" . $_POST['kol'] . "</b> ед. ресурса <b>" . mysql_result(myquery("SELECT name FROM craft_resource WHERE id='" . $_POST['res_id'] . "'"), 0, 0) . "</b> игроку <b>" . $_POST['name'] . "</b>',\n\t\t\t '" . time() . "',\n\t\t\t '" . $da['mday'] . "',\n\t\t\t '" . $da['mon'] . "',\n\t\t\t '" . $da['year'] . "')") or die(mysql_error()); echo 'Ресурс добавлен!<br>'; } else { echo 'Заполните форму для добавления ресурса игроку:<br>'; echo ' <form action="admin.php?opt=main&option=resource&user" method="post"> <link href="suggest/suggest.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="suggest/suggest.js"></script> Имя игрока:<input id="keyword" name="name" type="text" size="20" onkeyup="handleKeyUp(event)"><div style="display:none;" id="scroll"><div id="suggest"></div></div> </div><script>init();</script>'; $check_res = myquery("SELECT * FROM craft_resource ORDER BY binary name"); if (mysql_num_rows($check_res) > 0) { echo '<br>Название ресурса: <select name="res_id">'; while ($res = mysql_fetch_array($check_res)) { echo '<option value=' . $res['id'] . '>' . $res['name'] . '</option>'; } echo '</select>';