Exemplo n.º 1
0
 // if you've previously selected an item to purchase
 $result = mysql_query("SELECT * FROM phaos_shop_inventory WHERE shop_id='{$shop_id}' AND item_id='{$item_id}'");
 // $result = mysql_query ("SELECT * FROM phaos_misc_items WHERE id = '$item'");
 $inv_row = mysql_fetch_array($result);
 // $price = $inv_row["sell"];
 $number = intval($_REQUEST['number']);
 while ($number-- > 0) {
     // is your pack already too full?
     if ($character->invent_count() >= $character->max_inventory) {
         print "<big><b><font color=red>{$lang_shop['inv_full']}</font></b></big>\n\t\t\t\t<br> <br>\n\t\t\t\t<a href='town.php'>{$lang_shop['return']}</a>";
         exit;
     }
     // 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"];
Exemplo n.º 2
0
$current_time = time();
if (@$_REQUEST['spell_items']) {
    $result = mysql_query("SELECT * FROM phaos_spells_items WHERE id = '{$spell_items}'");
    if ($row = mysql_fetch_array($result)) {
        $price = $row["buy_price"];
        $req = $row["req_skill"];
    }
    if ($character->wisdom * 2 < $req) {
        //latest change: characters may buy spells up to twice their wisdom, even if it means they fumble.
        $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 {