function event_trigger_get_points($zone)
{
    global $userdata, $lang;
    //Define money value
    $win = rand($zone['zone_pointwin1'], $zone['zone_pointwin2']);
    adr_add_points($userdata['user_id'], $win);
    $message = '<img src="adr/images/zones/get_money.gif"><br /><br />' . $lang['Adr_zone_event_winpoint'] . ' ' . $win . ' ' . $board_config['points_name'] . '<br /><br />' . $lang['Adr_zone_event_return'] . '<br /><br />';
    message_die(GENERAL_ERROR, $message, 'Zones', '');
}
function adr_sell_item($item_id, $user_id)
{
    global $db, $adr_general;
    // Fix the values
    $user_id = intval($user_id);
    $item_id = intval($item_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, '');
    } else {
        adr_trading_limit($user_id);
    }
    // Get the item real price
    $temp_price = adr_get_item_real_price($item_id, $user_id);
    // Apply the trading skill modification
    $price = adr_use_skill_trading($user_id, $temp_price, sell);
    // Delete the item
    $sql = "DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_owner_id = {$user_id}\n\t\tAND item_id = {$item_id} ";
    $result = $db->sql_query($sql);
    if (!$result) {
        adr_previous(Adr_shop_items_failure_deleted, adr_character_inventory, '');
    }
    // Give points to the seller - has to be done at the end to prevent treacherous users !
    adr_add_points($user_id, $price);
}
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;
            }
        }
    }
}