function adr_buy_item($user_id, $item_id, $shop_owner_id, $shop_id, $direct, $nav) { global $db, $lang, $board_config, $phpEx, $userdata, $adr_general, $adr_user; // Fix the values $user_id = intval($user_id); $item_id = intval($item_id); $shop_owner_id = intval($shop_owner_id); $shop_id = intval($shop_id); $sql = "SELECT character_trading_limit FROM " . ADR_CHARACTERS_TABLE . "\n\t\t\tWHERE character_id = {$user_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain shops items information', "", __LINE__, __FILE__, $sql); } $trading_limit = $db->sql_fetchrow($result); if ($adr_general['Adr_character_limit_enable'] != 0 && $trading_limit['character_trading_limit'] < 1) { adr_previous(Adr_trading_limit, adr_shops, ''); } // Select the item infos $shop_more_sql = $shop_owner_id != 1 ? 'AND item_in_shop = 1' : ''; // Prevents users to buy items not in shops $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_owner_id = {$shop_owner_id}\n\t\tAND item_id = {$item_id} \n\t\t{$shop_more_sql} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain shops items information', "", __LINE__, __FILE__, $sql); } $item_data = $db->sql_fetchrow($result); // Check if the item exists if (!is_numeric($item_data['item_price'])) { adr_previous(Adr_lack_items, $direct, $nav); } // Calculate the sum using the trading skill $sum = $item_data['item_price']; $sum = adr_use_skill_trading($user_id, $sum, buy); // Substract the points adr_substract_points($user_id, $sum, $direct, $nav); // Make the new id for the item $sql = "SELECT item_id FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_owner_id = {$user_id}\n\t\tORDER BY item_id \n\t\tDESC LIMIT 1"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql); } $data = $db->sql_fetchrow($result); $new_item_id = $data['item_id'] + 1; // If the shop isn't the forums one , transfer , else duplicate if ($shop_owner_id != 1) { $sql = "UPDATE " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tSET item_owner_id = {$user_id} ,\n\t\t\t\titem_id = {$new_item_id} ,\n\t\t\t\titem_bought_timestamp = " . time() . ",\n\t\t\t\titem_in_shop = 0 ,\n\t\t\t\titem_auth = 0,\n\t\t\t\titem_donated_by = '',\n\t\t\t\titem_donated_timestamp = 0\n\t\t\tWHERE item_owner_id = {$shop_owner_id}\n\t\t\tAND item_id = {$item_id} "; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain shops items information', "", __LINE__, __FILE__, $sql); } // Give money to the seller adr_add_points($shop_owner_id, $sum); } else { // Insert item details adr_shop_insert_item($item_id, $new_item_id, $user_id, $shop_owner_id); } return $sum; }
message_die(GENERAL_ERROR, 'Could not obtain items information', "", __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . ADR_SHOPS_TABLE . "\n\t\t\t\tWHERE shop_owner_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not obtain items information', "", __LINE__, __FILE__, $sql); } // Remove all transaction logs for user store $sql = "DELETE FROM " . ADR_STORES_USER_HISTORY . "\n\t\t\t\tWHERE user_store_owner_id = '{$user_id}'"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete user store trans logs', "", __LINE__, __FILE__, $sql); } adr_previous(Adr_users_shops_deleted, adr_shops, ''); break; case 'save_new_shop': $adr_general = adr_get_general_config(); adr_substract_points($user_id, $adr_general['new_shop_price'], adr_shops, '?mode=create_shop'); $sql = "SELECT * FROM " . ADR_SHOPS_TABLE . "\n\t\t\t\tORDER BY shop_id \n\t\t\t\tDESC LIMIT 1"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, 'Could not obtain alignments information', "", __LINE__, __FILE__, $sql); } $fields_data = $db->sql_fetchrow($result); $shop_name = isset($_POST['shop_name']) ? trim($_POST['shop_name']) : trim($_GET['shop_name']); $shop_desc = isset($_POST['shop_desc']) ? trim($_POST['shop_desc']) : trim($_GET['shop_desc']); $shop_id = $fields_data['shop_id'] + 1; if (!$shop_name) { message_die(MESSAGE, $lang['Fields_empty']); } $sql = "INSERT INTO " . ADR_SHOPS_TABLE . " \n\t\t\t\t( shop_id , shop_name , shop_desc , shop_owner_id )\n\t\t\t\tVALUES ( {$shop_id} ,'" . str_replace("\\'", "''", $shop_name) . "','" . str_replace("\\'", "''", $shop_desc) . "', {$user_id} )"; $result = $db->sql_query($sql); if (!$result) {
} $template->assign_block_vars('training.train_class', array()); if ($userdata['user_level'] == ADMIN) { $sql_level = ''; } else { if ($userdata['user_level'] == MOD) { $sql_level = ' AND c.class_level <> 1'; } else { $sql_level = 'AND c.class_level = 0'; } } $sql = "SELECT c.* FROM " . ADR_CLASSES_TABLE . " c , " . ADR_CHARACTERS_TABLE . " u\r\t\t\t\t\t\t\tWHERE c.class_might_req < u.character_might\r\t\t\t\t\t\t\t{$sql_level}\r\t\t\t\t\t\t\tAND c.class_dexterity_req <= u.character_dexterity\r\t\t\t\t\t\t\tAND c.class_constitution_req <= u.character_constitution\r\t\t\t\t\t\t\tAND c.class_intelligence_req <= u.character_intelligence\r\t\t\t\t\t\t\tAND c.class_wisdom_req <= u.character_wisdom\r\t\t\t\t\t\t\tAND c.class_charisma_req <= u.character_charisma\r\t\t\t\t\t\t\tAND c.class_selectable = 1\r\t\t\t\t\t\t\tAND u.character_id = {$user_id} "; if (!($result = $db->sql_query($sql))) { message_die(CRITICAL_ERROR, 'Error Getting ADR Classes!'); } $class = $db->sql_fetchrowset($result); if (count($class) < 1) { adr_previous(Adr_town_training_grounds_change_class_lack_class, adr_town, "mode=training"); } for ($i = 0; $i < count($class); $i++) { $template->assign_block_vars('training.train_class.classes', array("CLASS_NAME" => adr_get_lang($class[$i]['class_name']), "CLASS_DESC" => adr_get_lang($class[$i]['class_desc']), "CLASS_IMG" => $class[$i]['class_img'], "CLASS_ID" => $class[$i]['class_id'], "UPDATE_XP_REQ" => $class[$i]['class_update_xp_req'], "UPDATE_HP" => $class[$i]['class_update_hp'], "UPDATE_MP" => $class[$i]['class_update_mp'], "UPDATE_AC" => $class[$i]['class_update_ac'])); } $hidden = 'change_class_action'; $template->assign_vars(array('L_NAME' => $lang['Adr_races_name'], 'L_DESC' => $lang['Adr_races_desc'], 'L_IMG' => $lang['Adr_races_image'], "L_UPDATE_HP" => $lang['Adr_classes_update_hp'], "L_UPDATE_MP" => $lang['Adr_classes_update_mp'], "L_UPDATE_AC" => $lang['Adr_classes_update_ac'], "L_NEW_CHARACTER_CLASS_DESC" => $lang['Adr_races_desc'], "L_NEW_CHARACTER_CLASS_CHOOSE" => $lang['Select'], "L_SELECT_UPGRADE" => $lang['Adr_town_training_grounds_change_class_upgrade'], "L_SELECT_UPGRADE_ACTION" => $lang['Adr_town_training_grounds_change_class'], "L_SELECT_UPGRADE_COST" => sprintf($lang['Adr_town_training_grounds_change_class_cost'], $adr_general['training_change_cost'], $board_config['points_name']), "S_HIDDEN" => $hidden)); break; case 'change_class_action': $new_class = intval($HTTP_POST_VARS['new_class']); if (!$new_class) { adr_previous(Adr_town_training_grounds_change_class_must, adr_town, "mode=training&sub_mode=change_class"); } adr_substract_points($user_id, $adr_general['training_change_cost'], adr_town, "mode=training&sub_mode=change_class");
} if ($adr_char['character_hp'] == $adr_char['character_hp_max'] && $adr_char['character_mp'] == $adr_char['character_mp_max']) { adr_previous(Adr_temple_heal_not, adr_temple, ''); } adr_substract_points($user_id, $heal_price, adr_temple, ''); $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\tSET character_hp = character_hp_max ,\n\t\t character_mp = character_mp_max\n\t\tWHERE character_id = {$user_id} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Can not update the user characteristics'); } adr_previous(Adr_temple_healed, adr_temple, ''); } else { if ($resurrect) { if ($adr_char['character_hp'] > 0) { adr_previous(Adr_temple_heal_instead, adr_temple, ''); } adr_substract_points($user_id, $resurrect_price, adr_temple, ''); $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\tSET character_hp = character_hp_max ,\n\t\t character_mp = character_mp_max\n\t\tWHERE character_id = {$user_id} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Can not update the user characteristics'); } adr_previous(Adr_temple_resurrected, adr_temple, ''); } else { $template->assign_vars(array('HEAL_COST' => $heal_price, 'RESURRECT_COST' => $resurrect_price, 'L_TEMPLE' => $lang['Adr_temple'], 'L_HEAL_COST' => $lang['Adr_temple_heal_cost'], 'L_RESURRECT_COST' => $lang['Adr_temple_resurrect_cost'], 'L_HEAL' => $lang['Adr_temple_heal'], 'L_RESURRECT' => $lang['Adr_temple_resurrect'], 'L_POINTS' => $board_config['points_name'], 'S_CHARACTER_ACTION' => append_sid("adr_temple.{$phpEx}"))); } } include $phpbb_root_path . 'adr/includes/adr_header.' . $phpEx; $template->pparse('body'); include $phpbb_root_path . 'includes/page_tail.' . $phpEx; ?>
function event_trigger_ambush($zone) { global $userdata, $lang, $user_id; //Define money value $loss = rand($zone['zone_pointloss1'], $zone['zone_pointloss2']); if ($loss > $userdata['user_points']) { $loss = $userdata['user_points']; } adr_substract_points($user_id, $loss, 'adr_zones', ''); $message = '<img src="adr/images/zones/ambush.gif"><br /><br />' . $lang['Adr_zone_event_ambush'] . ' ' . $loss . ' ' . $board_config['points_name'] . '<br /><br />' . $lang['Adr_zone_event_battle'] . '<br />' . $lang['Adr_zone_event_return'] . '<br /><br />'; message_die(GENERAL_ERROR, $message, 'Zones', ''); }
function zone_npc_actions() { global $db, $userdata, $area_id, $user_id, $lang, $adr_user, $user_npc_visit_array, $user_npc_quest_array; if (isset($_GET['npc']) || isset($_POST['npc'])) { $npc_action = isset($_POST['npc']) ? intval($_POST['npc']) : intval($_GET['npc']); } $npc_give_action = isset($_POST['npc_give']) ? $_POST['npc_give'] : null; if (isset($npc_action)) { // Deny access if user is imprisioned if ($userdata['user_cell_time']) { adr_previous('Adr_zone_no_thief_npc', 'adr_cell', ''); } if (isset($_GET['npc_id']) || isset($_POST['npc_id'])) { $npc_id = isset($_POST['npc_id']) ? intval($_POST['npc_id']) : intval($_GET['npc_id']); } $adr_user = adr_npc_visit_update($npc_id, $adr_user); $sql = "SELECT * FROM " . ADR_NPC_TABLE . "\n\t\t\t\tWHERE npc_id = '{$npc_id}'\n\t\t\t\t\tAND npc_enable = '1'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query npc information', '', __LINE__, __FILE__, $sql); } //prevent user exploit if (!($npc_row = $db->sql_fetchrow($result))) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } $npc_zone_array = explode(',', $npc_row['npc_zone']); $npc_race_array = explode(',', $npc_row['npc_race']); $npc_class_array = explode(',', $npc_row['npc_class']); $npc_alignment_array = explode(',', $npc_row['npc_alignment']); $npc_element_array = explode(',', $npc_row['npc_element']); $npc_character_level_array = explode(',', $npc_row['npc_character_level']); $npc_visit_array = explode(',', $npc_row['npc_visit_prerequisite']); $npc_quest_array = explode(',', $npc_row['npc_quest_prerequisite']); $npc_visit = array(); $npc_quest = array(); $no_talk_message = array(); $npc_quest_hide_array = array(); // you can't click a disabled npc if (!$npc_row['npc_enable']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } // you can't click a npc in another area if (!in_array($area_id, $npc_zone_array) && $npc_zone_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!in_array($adr_user['character_race'], $npc_race_array) && $npc_race_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array($adr_user['character_race'], $npc_race_array) && $npc_race_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[] = $lang['Adr_Npc_race_no_talk_message']; } } if (!in_array($adr_user['character_class'], $npc_class_array) && $npc_class_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array($adr_user['character_class'], $npc_class_array) && $npc_class_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[] = $lang['Adr_Npc_class_no_talk_message']; } } if (!in_array($adr_user['character_alignment'], $npc_alignment_array) && $npc_alignment_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array($adr_user['character_alignment'], $npc_alignment_array) && $npc_alignment_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[] = $lang['Adr_Npc_alignment_no_talk_message']; } } if (!in_array($adr_user['character_element'], $npc_element_array) && $npc_element_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array($adr_user['character_element'], $npc_element_array) && $npc_element_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[] = $lang['Adr_Npc_element_no_talk_message']; } } if (!in_array($adr_user['character_level'], $npc_character_level_array) && $npc_character_level_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array($adr_user['character_level'], $npc_character_level_array) && $npc_character_level_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[] = $lang['Adr_Npc_character_level_no_talk_message']; } } for ($y = 0; $y < count($user_npc_visit_array); $y++) { $npc_visit[$y] = in_array($user_npc_visit_array[$y], $npc_visit_array) ? '1' : '0'; } if (!in_array('1', $npc_visit) && $npc_visit_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array('1', $npc_visit) && $npc_visit_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[] = $lang['Adr_Npc_character_visit_no_talk_message']; } } for ($y = 0; $y < count($user_npc_quest_array); $y++) { $npc_quest_id = explode(':', $user_npc_quest_array[$y]); $npc_quest[$y] = in_array($npc_quest_id[0], $npc_quest_array) ? '1' : '0'; $npc_quest_hide_array[$y] = $npc_quest_id[0] == $npc_row['npc_id'] ? '1' : '0'; } if (!in_array('1', $npc_quest) && $npc_quest_array[0] != '0' && !$npc_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } else { if (!in_array('1', $npc_quest) && $npc_quest_array[0] != '0' && $npc_row['npc_view']) { $no_talk_message[$x] = $lang['Adr_Npc_character_quest_no_talk_message']; } } if (in_array('1', $npc_quest_hide_array) && $npc_row['npc_quest_hide']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } $adr_moderators_array = explode(',', $board_config['zone_adr_moderators']); if ($npc_row['npc_user_level'] != '0' && !($npc_row['npc_user_level'] == '1' && $userdata['user_level'] == ADMIN || $npc_row['npc_user_level'] == '2' && (in_array($user_id, $adr_moderators_array) || $userdata['user_level'] == ADMIN))) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } //---- adr_substract_points($user_id, $npc_row['npc_price'], 'adr_zones', ''); if (count($no_talk_message)) { $message_id = rand(0, count($no_talk_message) - 1); $message = "<img src=\"adr/images/zones/npc/" . $npc_row['npc_img'] . "\"><br /><br /><b>" . $npc_row['npc_name'] . ":</b> <i>\"" . $no_talk_message[$message_id] . "\"</i><br /><br />" . $lang['Adr_zone_event_return']; $adr_zone_npc_title = sprintf($lang['Adr_Npc_speaking_with'], $npc_row['npc_name']); message_die(GENERAL_MESSAGE, $message, $adr_zone_npc_title, ''); break; } else { if (adr_item_quest_check($npc_row['npc_id'], $adr_user['character_npc_check'], $npc_row['npc_times'])) { zone_npc_item_quest_check($npc_row); } else { $message = "<img src=\"adr/images/zones/npc/" . $npc_row['npc_img'] . "\"><br /><br /><b>" . $npc_row['npc_name'] . ":</b> <i>\"" . $npc_row['npc_message3'] . "\"</i><br /><br />" . $lang['Adr_zone_event_return']; $adr_zone_npc_title = sprintf($lang['Adr_Npc_speaking_with'], $npc_row['npc_name']); message_die(GENERAL_ERROR, $message, $adr_zone_npc_title, ''); break; } } } else { if (isset($npc_give_action)) { $npc_id = intval($_POST['npc_id']); $item_id_array = explode(',', $_POST['item_id']); $sql = "SELECT * FROM " . ADR_NPC_TABLE . "\n\t\t\t\tWHERE npc_id = '{$npc_id}'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query npc information', '', __LINE__, __FILE__, $sql); } //prevent user exploit if (!($npc_give_row = $db->sql_fetchrow($result))) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!$npc_give_row['npc_enable']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } // V: let's add some security to this bullshit. $sql = "SELECT * FROM " . ADR_QUEST_LOG_TABLE . "\n\t\t\t\t\t \t\tWHERE user_id = '{$user_id}'\n\t\t\t\t\t\t\tAND npc_id = '{$npc_id}'\n\t\t\t\t\t\t\t"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query quest log information', __LINE__, __FILE__, $sql); } $quest = $db->sql_fetchrow($result); if (!$quest) { $message = "<img src=\"adr/images/zones/npc/" . $npc_give_row['npc_img'] . "\"><br /><br /><b>" . $lang['npc_cant_give_quest_u_dont_have'] . "</b><br /><br />" . $lang['Adr_zone_event_return']; $adr_zone_npc_title = sprintf($lang['Adr_Npc_speaking_with'], $npc_row['npc_name']); message_die(GENERAL_ERROR, $message, $adr_zone_npc_title, ''); break; } $npc_zone_array = explode(',', $npc_give_row['npc_zone']); $npc_race_array = explode(',', $npc_give_row['npc_race']); $npc_class_array = explode(',', $npc_give_row['npc_class']); $npc_alignment_array = explode(',', $npc_give_row['npc_alignment']); $npc_element_array = explode(',', $npc_give_row['npc_element']); $npc_character_level_array = explode(',', $npc_give_row['npc_character_level']); $npc_visit_array = explode(',', $npc_give_row['npc_visit_prerequisite']); $npc_quest_array = explode(',', $npc_give_row['npc_quest_prerequisite']); $npc_visit = array(); $npc_quest = array(); $npc_quest_hide_array = array(); if (!in_array($area_id, $npc_zone_array) && $npc_zone_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!in_array($adr_user['character_race'], $npc_race_array) && $npc_race_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!in_array($adr_user['character_class'], $npc_class_array) && $npc_class_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!in_array($adr_user['character_alignment'], $npc_alignment_array) && $npc_alignment_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!in_array($adr_user['character_element'], $npc_element_array) && $npc_element_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!in_array($adr_user['character_level'], $npc_character_level_array) && $npc_character_level_array[0] != '0') { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } for ($y = 0; $y < count($user_npc_visit_array); $y++) { $npc_visit[$y] = in_array($user_npc_visit_array[$y], $npc_visit_array) ? '1' : '0'; } if (!in_array('1', $npc_visit) && $npc_visit_array[0] != '0' && !$npc_give_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } for ($y = 0; $y < count($user_npc_quest_array); $y++) { $npc_quest_id = explode(':', $user_npc_quest_array[$y]); $npc_quest[$y] = in_array($npc_quest_id[0], $npc_quest_array) ? '1' : '0'; $npc_quest_hide_array[$y] = $npc_quest_id[0] == $npc_give_row['npc_id'] ? '1' : '0'; } if (!in_array('1', $npc_quest) && $npc_quest_array[0] != '0' && !$npc_give_row['npc_view']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (in_array('1', $npc_quest_hide_array) && $npc_give_row['npc_quest_hide']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } $adr_moderators_array = explode(',', $board_config['zone_adr_moderators']); if ($npc_give_row['npc_user_level'] != '0' && !($npc_give_row['npc_user_level'] == '1' && $userdata['user_level'] == ADMIN || $npc_give_row['npc_user_level'] == '2' && (in_array($user_id, $adr_moderators_array) || $userdata['user_level'] == ADMIN))) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } if (!$npc_give_row['npc_quest_clue']) { // Check if user has the item(s) $npc_item_array = explode(',', $npc_give_row['npc_item']); for ($i = 0; $i < count($npc_item_array); $i++) { $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t \t\t\t\t\tWHERE item_id = '" . $item_id_array[$i] . "'\n\t \t\t\t\t\t AND item_name = '" . $npc_item_array[$i] . "'\n\t \t\t\t\t\t\tAND item_owner_id = '{$user_id}'\n\t\t \t\t\t\t\tAND item_in_shop = '0'\n\t\t\t \t\t\t\tAND item_in_warehouse = '0'\n\t\t\t\t\t\tLIMIT 1 "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not query shop item information', '', __LINE__, __FILE__, $sql); } $item_npc = $db->sql_fetchrowset($result); if (count($item_npc) == 0 && ($npc_give_row['npc_kill_monster'] == "" or $npc_give_row['npc_kill_monster'] == '0')) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_1']); } } } else { if (!$npc_give_row['npc_quest_clue']) { adr_item_quest_cheat_notification($user_id, $lang['Adr_zone_npc_cheating_type_2']); } } if (adr_item_quest_check($npc_give_row['npc_id'], $adr_user['character_npc_check'], $npc_give_row['npc_times'])) { if (!$npc_give_row['npc_quest_clue']) { //Delete item(s) from character inventory for ($i = 0; $i < count($npc_item_array); $i++) { $delsql = "DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE item_owner_id = '{$user_id}'\n\t\t\t\t\t\t\t\t\tAND item_id = '" . $item_id_array[$i] . "' "; if (!($aresult = $db->sql_query($delsql))) { message_die(GENERAL_ERROR, "Couldn't update inventory info", "", __LINE__, __FILE__, $asql); } $sql5 = "SELECT * FROM " . ADR_QUEST_LOG_TABLE . "\n\t\t\t\t\t\tWHERE quest_item_need like '" . $npc_item_array[$i] . "," . "%' \n\t\t\t\t\t\tOR quest_item_need like '" . $npc_item_array[$i] . "'\n\t\t\t\t\t\tOR quest_item_need like '" . $npc_item_array[$i] . "," . "'\n\t\t\t\t\t\tOR quest_item_need like '%" . "," . $npc_item_array[$i] . "," . "%'\n\t\t\t\t\t\tOR quest_item_need like '%" . "," . $npc_item_array[$i] . "'\n\t\t\t\t\t\tAND user_id = '{$user_id}'\n\t\t\t\t\t\t"; $cresult = $db->sql_query($sql5); if (!$cresult) { message_die(GENERAL_ERROR, 'Could not obtain required quest information', "", __LINE__, __FILE__, $sql5); } if ($got_item_log = $db->sql_fetchrow($cresult)) { $got_item += 1; } if ($got_item == count($npc_item_array) && ($npc_give_row['npc_kill_monster'] == '0' || $npc_give_row['npc_kill_monster'] == "")) { //Copy Quest to the History $insertsql = "INSERT INTO " . ADR_QUEST_LOG_HISTORY_TABLE . "\n\t\t\t\t\t\t\t( user_id, quest_killed_monster , quest_killed_monsters_amount , npc_id, quest_item_gave)\n\t\t\t\t\t\t\tVALUES ( '{$user_id}' , '" . $npc_give_row['npc_kill_monster'] . "' , '" . $npc_give_row['npc_monster_amount'] . "' , '" . $npc_give_row['npc_id'] . "', '" . $npc_give_row['npc_item'] . "' )"; $result = $db->sql_query($insertsql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert finished quest", "", __LINE__, __FILE__, $insertsql); } //Delete the Quest of the log $delsql2 = " DELETE FROM " . ADR_QUEST_LOG_TABLE . "\n\t\t\t\t\t \t\tWHERE user_id = '{$user_id}'\n\t\t\t\t\t\t\tAND npc_id = '{$npc_id}'\n\t\t\t\t\t \t\t"; if (!($bresult = $db->sql_query($delsql2))) { message_die(GENERAL_ERROR, "Couldn't update questlog info", "", __LINE__, __FILE__, $delsql2); } } } if ($npc_give_row['npc_kill_monster'] != '0' && $npc_give_row['npc_kill_monster'] != "" && $npc_give_row['quest_kill_monster_current_amount'] == $npc_give_row['npc_kill_monster_amount']) { //Copy Quest to the History $insertsql = "INSERT INTO " . ADR_QUEST_LOG_HISTORY_TABLE . "\n\t\t\t\t\t\t( user_id, quest_killed_monster , quest_killed_monsters_amount , npc_id, quest_item_gave)\n\t\t\t\t\t\tVALUES ( '{$user_id}' , '" . $npc_give_row['npc_kill_monster'] . "' , '" . $npc_give_row['npc_monster_amount'] . "' , '" . $npc_give_row['npc_id'] . "', '" . $npc_give_row['npc_item'] . "' )"; $result = $db->sql_query($insertsql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert finished quest", "", __LINE__, __FILE__, $insertsql); } //Delete the Quest of the log $delsql3 = " DELETE FROM " . ADR_QUEST_LOG_TABLE . "\n\t\t\t \t\t\tWHERE quest_kill_monster = '" . $npc_give_row['npc_kill_monster'] . "'\n\t\t\t \t\t\tAND quest_kill_monster_current_amount = '" . $npc_give_row['npc_monster_amount'] . "'\n\t\t\t\t\t\tAND user_id = '{$user_id}'\n\t\t\t\t\t\tAND npc_id = '{$npc_id}'\n\t\t\t\t \t\t"; if (!($dresult = $db->sql_query($delsql3))) { message_die(GENERAL_ERROR, "Couldn't update questlog info", "", __LINE__, __FILE__, $delsql3); } } } else { adr_substract_points($user_id, $npc_give_row['npc_quest_clue_price'], adr_zones, ''); //Delete the Quest of the log $delsql2 = " DELETE FROM " . ADR_QUEST_LOG_TABLE . "\n\t\t\t \t\tWHERE user_id = '{$user_id}'\n\t\t\t\t\tAND npc_id = '{$npc_id}'\n\t\t\t \t\t"; if (!($bresult = $db->sql_query($delsql2))) { message_die(GENERAL_ERROR, "Couldn't update questlog info", "", __LINE__, __FILE__, $delsql2); } } //give points prize adr_add_points($user_id, $npc_give_row['npc_points']); //give exp and sp prize $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\t\t\t\tSET character_xp = character_xp + '" . $npc_give_row['npc_exp'] . "',\n\t\t\t\t\t\tcharacter_sp = character_sp + '" . $npc_give_row['npc_sp'] . "'\n\t\t\t\t\tWHERE character_id = '{$user_id}' "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update character information', '', __LINE__, __FILE__, $sql); } $prize_item = ''; if ($npc_give_row['npc_item2'] != "0" && $npc_give_row['npc_item2'] != "") { $npc_item2_array = explode(',', $npc_give_row['npc_item2']); for ($i = 0; $i < count($npc_item2_array); $i++) { adr_shop_insert_item($npc_item2_array[$i], adr_make_new_item_id($user_id), $user_id, 1, 0, 0, 'item_name'); if (count($npc_item2_array) == 1) { $prize_item .= adr_get_lang($npc_item2_array[$i]); } else { if ($i >= 1 && $i == count($npc_item2_array) + 1) { $prize_item .= ' and ' . adr_get_lang($npc_item2_array[$i]); } else { $prize_item .= ', ' . adr_get_lang($npc_item2_array[$i]); } } } $prize_message = sprintf($lang['Adr_zone_npc_item_prize'], $npc_give_row['npc_name'], $prize_item); } //Insert Character in check field if ($npc_give_row['npc_times'] > 0) { adr_item_quest_check_insert($adr_user['character_npc_check'], $npc_give_row['npc_id'], $user_id); } //---- $points_prize_lang = $npc_give_row['npc_points'] == 0 ? "" : sprintf($lang['Adr_zone_npc_points_prize'], number_format(intval($npc_give_row['npc_points'])), $board_config['points_name']); $exp_prize_lang = $npc_give_row['npc_exp'] == 0 ? "" : sprintf($lang['Adr_zone_npc_exp_prize'], number_format(intval($npc_give_row['npc_exp']))); $sp_prize_lang = $npc_give_row['npc_sp'] == 0 ? "" : sprintf($lang['Adr_zone_npc_sp_prize'], number_format(intval($npc_give_row['npc_sp']))); $item_prize_lang = count($npc_item2_array) == 0 || $npc_give_row['npc_item2'] == "" ? "" : $prize_message; $message = "<img src=\"adr/images/zones/npc/" . $npc_give_row['npc_img'] . "\"><br /><br /><b>" . $npc_give_row['npc_name'] . ":</b> <i>\"" . $npc_give_row['npc_message2'] . "\"</i><br /><br />" . $item_prize_lang . "" . $points_prize_lang . "" . $exp_prize_lang . "" . $sp_prize_lang . "<br />" . $lang['Adr_zone_event_return']; $adr_zone_npc_title = sprintf($lang['Adr_Npc_speaking_with'], $npc_row['npc_name']); message_die(GENERAL_ERROR, $message, $adr_zone_npc_title, ''); break; } else { $message = "<img src=\"adr/images/zones/npc/" . $npc_give_row['npc_img'] . "\"><br /><br /><b>" . $npc_give_row['npc_name'] . ":</b> <i>\"" . $npc_give_row['npc_message2'] . "\"</i><br /><br />" . $lang['Adr_zone_event_return']; $adr_zone_npc_title = sprintf($lang['Adr_Npc_speaking_with'], $npc_row['npc_name']); message_die(GENERAL_ERROR, $message, $adr_zone_npc_title, ''); break; } } } }
if ($destination_zone_required_level && $destination_zone_required_item && $destination_zone_return_cost && $destination_zone_required_scroll && $teleport_enable) { $template->assign_block_vars('switch_Adr_zone_teleport_enable', array()); } //Display Required Items? if ($board_config['Adr_zone_townmap_display_required']) { $template->assign_block_vars('switch_Adr_zone_townmap_display_required', array()); } //Change Item to No Item if no item is required if ($destination_required_item == '0') { $destination_required_item_text = $lang['Adr_zone_maps_item_nothing']; } else { $destination_required_item_text = $destination_required_item; } //teleport the player if ($destination_zone_required_level && $destination_zone_required_item && $destination_zone_return_cost && $destination_zone_required_scroll && $teleport == $lang['Adr_zone_maps_teleport_to_zone']) { adr_substract_points($user_id, $cost_return, adr_zones, ''); $new_scroll_item_duration = $scroll_item_duration - 1; //Update character zone $sql = " UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\tSET character_area = '{$destination_zone_id}'\r\n\t\t\tWHERE character_id = '{$user_id}' "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not update character zone', '', __LINE__, __FILE__, $sql); } $sql = " UPDATE " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tSET item_duration = '{$new_scroll_item_duration}'\r\n\t\t\tWHERE item_id = '{$scroll_item_id}' "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, $lang['Adr_zone_maps_error_message_6'], '', __LINE__, __FILE__, $sql); } // Delete broken items from users inventory if ($new_scroll_item_duration < 1) { $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\tWHERE item_duration < 1\r\n \t\t\t\tAND item_in_shop = '0'\r\n\t\t\t\tAND item_in_warehouse = '0'\r\n\t\t\t\tAND item_owner_id = {$user_id} "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, $lang['Adr_zone_maps_error_message_7'], '', __LINE__, __FILE__, $sql);
} $recipebook_data = $db->sql_fetchrow($result); $new_recipe_id = $recipebook_data['recipe_id'] + 1; //write recipe into the owners recipebook $sql = "INSERT INTO " . ADR_RECIPEBOOK_TABLE . " \r\n\t\t\t\t\t\t\t\t( recipe_id , recipe_owner_id , recipe_level , recipe_linked_item , recipe_items_req , recipe_effect , recipe_original_id, recipe_skill_id)\r\n\t\t\t\t\t\t\t\tVALUES ( {$new_recipe_id} , {$user_id} , '" . $admin_recipe['item_power'] . "' , '" . $admin_recipe['item_recipe_linked_item'] . "' , '" . $admin_recipe['item_brewing_items_req'] . "', '" . $admin_recipe['item_effect'] . "', '" . $admin_recipe['item_original_recipe_id'] . "', '" . $admin_recipe['item_recipe_skill_id'] . "')"; $result = $db->sql_query($sql); if (!$result) { message_die(GENERAL_ERROR, "Couldn't insert new recipe into the recipebook", "", __LINE__, __FILE__, $sql); } } } } } else { if ($research_keep != 0) { // Extra cost for keeping learned information adr_substract_points($user_id, 1000, '', adr_research); // Get learned infomation $sql = "SELECT book_id FROM " . ADR_LIBRARY_LEARN_TABLE . "\r\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}\r\n\t\t\t\t\t\t\tAND book_id = " . $rand_library['book_id']; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Couldn't get learned information", "", __LINE__, __FILE__, $sql); } $row_learn = $db->sql_fetchrow($result); // Check to see if you already know this information if ($row_learn == '') { $sql_learn = "INSERT INTO " . ADR_LIBRARY_LEARN_TABLE . "\r\n\t\t\t\t\t\t\t(user_id, book_id, book_name, book_details)\r\n\t\t\t\t\t\t\tVALUES ({$user_id}, " . $rand_library['book_id'] . ", '" . $rand_library['book_name'] . "', '" . $rand_library['book_details'] . "')"; if (!($result_learn = $db->sql_query($sql_learn))) { message_die(GENERAL_ERROR, "Couldn't insert learned information", "", __LINE__, __FILE__, $sql_learn); } } else { $sql_learn = "UPDATE " . ADR_LIBRARY_LEARN_TABLE . "\r\n\t\t\t\t\t\t\t\tSET book_name = '" . $rand_library['book_name'] . "',\r\n\t\t\t\t\t\t\t\t\tbook_details = '" . $rand_library['book_details'] . "'\r\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}\r\n\t\t\t\t\t\t\t\tAND book_id = " . $rand_library['book_id']; if (!($result_learn = $db->sql_query($sql_learn))) {
$class = $db->sql_fetchrowset($result); if (count($class) < 1) { adr_previous(Adr_town_training_grounds_change_class_lack_class, adr_TownMap_Entrainement, "mode=training"); } for ($i = 0; $i < count($class); $i++) { $template->assign_block_vars('training.train_class.classes', array("CLASS_NAME" => adr_get_lang($class[$i]['class_name']), "CLASS_DESC" => adr_get_lang($class[$i]['class_desc']), "CLASS_IMG" => $class[$i]['class_img'], "CLASS_ID" => $class[$i]['class_id'], "UPDATE_XP_REQ" => $class[$i]['class_update_xp_req'], "UPDATE_HP" => $class[$i]['class_update_hp'], "UPDATE_MP" => $class[$i]['class_update_mp'], "UPDATE_AC" => $class[$i]['class_update_ac'])); } $hidden = 'change_class_action'; $template->assign_vars(array('L_NAME' => $lang['Adr_races_name'], 'L_DESC' => $lang['Adr_races_desc'], 'L_IMG' => $lang['Adr_races_image'], "L_UPDATE_HP" => $lang['Adr_classes_update_hp'], "L_UPDATE_MP" => $lang['Adr_classes_update_mp'], "L_UPDATE_AC" => $lang['Adr_classes_update_ac'], "L_NEW_CHARACTER_CLASS_DESC" => $lang['Adr_races_desc'], "L_NEW_CHARACTER_CLASS_CHOOSE" => $lang['Select'], "L_SELECT_UPGRADE" => $lang['Adr_town_training_grounds_change_class_upgrade'], "L_SELECT_UPGRADE_ACTION" => $lang['Adr_town_training_grounds_change_class'], "L_SELECT_UPGRADE_COST" => sprintf($lang['Adr_town_training_grounds_change_class_cost'], $adr_general['training_change_cost'], $board_config['points_name']), "S_HIDDEN" => $hidden)); break; case 'change_class_action': $new_class = intval($HTTP_POST_VARS['new_class']); if (!$new_class) { adr_previous(Adr_town_training_grounds_change_class_must, adr_TownMap_Entrainement, "mode=training&sub_mode=change_class"); } adr_substract_points($user_id, $adr_general['training_change_cost'], adr_TownMap_Entrainement, "mode=training&sub_mode=change_class"); $sql = " UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\t\t\t\t\tSET character_class = {$new_class}\r\n\t\t\t\t\t\t\tWHERE character_id = {$user_id} "; if (!$db->sql_query($sql)) { message_die(CRITICAL_ERROR, 'Error updating ADR Classes!'); } adr_update_posters_infos(); adr_previous(Adr_town_training_grounds_change_class_done, adr_character, ''); break; } } break; } } else { $template->assign_block_vars('main', array()); } // Fix the values