コード例 #1
0
ファイル: adr_shops.php プロジェクト: ZerGabriel/adr-rpg
         }
         // Check for user_points
         if (get_reward($user_id) < $item_price) {
             adr_previous(Adr_lack_points, adr_shops, $nav);
         } else {
             for ($j = 0; $j < $quantity; $j++) {
                 $price = adr_buy_item($user_id, $item_id, $shop_owner_id, $shop_id, adr_shops, "see_shop&amp;shop_id=" . $shop_id . "");
                 $sum = intval($sum + $price);
                 $buying_checks = TRUE;
             }
         }
     }
 }
 // Remove quota
 if ($buying_checks == TRUE && $adr_general['Adr_character_limit_enable'] == '1') {
     adr_trading_limit($user_id);
 }
 if ($shop_owner_id > '1') {
     // Update user store transaction log
     if (count($items) > '0') {
         adr_update_store_user_trans($user_id, $shop_owner_id, $items, $sum, $invent_array);
     }
     $direction = append_sid("adr_shops.{$phpEx}?mode=see_shop&amp;shop_id=" . $shop_id);
 } elseif ($shop_owner_id == '1') {
     // Update store status
     adr_update_store_status($user_id, $store_id, $items, $quantity);
     $direction = append_sid("adr_shops.{$phpEx}?mode=view_store&amp;shop_id=" . $shop_id);
 }
 // Create confirmation msg
 $message = sprintf($lang['Adr_buy_item_success'], $sum, $points_name);
 $message .= '<br /><br />' . sprintf($lang['Adr_return'], "<a href=\"" . $direction . "\">", "</a>");
コード例 #2
0
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);
}