Ejemplo n.º 1
0
        }
        // is the item still in stock?
        if (--$inv_row["quantity"] >= 0) {
            // do you have enough gold to buy the item?
            if ($character->pay($inv_row["sell"])) {
                // reduce player gold if they have enough
                // give gold to owner
                $result = mysql_query("SELECT * FROM phaos_buildings WHERE shop_id='{$shop_id}' ");
                $shop_row = mysql_fetch_array($result);
                $owner = new character($shop_row["owner_id"]);
                $owner->gold += $inv_row["sell"];
                $result = mysql_query("UPDATE phaos_characters\n\t\t\t\t\tSET gold='" . $owner->gold . "'\n\t\t\t\t\tWHERE id='" . $owner->id . "' ") or die(mysql_error());
                // remove item from store inventory
                $result = mysql_query("UPDATE phaos_shop_inventory\n\t\t\t\t\tSET quantity='{$inv_row['quantity']}'\n\t\t\t\t\tWHERE shop_id='{$shop_id}' AND item_id='{$item_id}' ") or die(mysql_error());
                // add item to player inventory
                $character->add_item($item_id, $inv_row["type"]);
                // $character->add_item($item,"misc_items");
                $refresh = 1;
            } else {
                $sorry = $lang_shop["sorry"];
                break;
            }
        } else {
            $sorry = $lang_shop["no_left"];
            break;
        }
    }
    // $refresh=1;
}
if ($refresh) {
    echo " <script language=\"JavaScript\">\n\t\t<!--\n\t\tjavascript:parent.side_bar.location.reload();\n\t\t//-->\n\t\t\t</script>";
Ejemplo n.º 2
0
        $sorry = $lang_shop["sorry_w"];
    } else {
        if ($price * $number_purchased <= $character->gold) {
            if ($number_purchased > 20) {
                $number_purchased = 20;
            }
            if ($character->pay($price * $number_purchased)) {
                if ($number_purchased < 0) {
                    $character->pay(-$price * $number_purchased);
                    $number_purchased = 0;
                    $sorry = $lang_shop["negative"];
                }
                $i = 0;
                while ($i < $number_purchased) {
                    $i++;
                    $character->add_item($spell_items, "spell_items");
                }
            } else {
                $sorry = $lang_shop["sorry"];
            }
            $refresh = 1;
        } else {
            $sorry = $lang_shop["sorry"];
        }
    }
    $refresh = 1;
}
if ($refresh) {
    echo " <script language=\"JavaScript\">\n               <!--\n               javascript:parent.side_bar.location.reload();\n               //-->\n               </script>";
}
$refresh = 0;