Main Menu
  • Welcome to The RPG Maker Resource Kit.

"Buy Only" in Shops

Started by GhstHawk, December 30, 2006, 06:27:45 AM

0 Members and 1 Guest are viewing this topic.

GhstHawk

I'm working on a system in my game that has several variables that can be spent as money. In RM2K and 2K3, there was a "Buy Only" option for shops, which I really need, but its not there anymore. How would I go about preventing selling for certain shops?
Secret of the Summit: [Working Title]
Scripts: nearly complete (need skill shop)
Storyline: complete
Database: 50%
Game Progress: 10%


italianstal1ion

here you go:

Made by Sandgolem at gamebaker.com

QuoteThis script allows you to prevent shops from buying types of items, or only buying certain items of a type. Can be mixed, you can make one shop that will only buy armors #1-10 and no items/weapons for example. Each shop can have their own settings, with no script editing required.

#==========================================================================
# ** SG Limited Shop Selling
#==========================================================================
# sandgolem
# Version 3
# 26.04.06
#==========================================================================

# Instruct: http://www.gamebaker.com/rmxp/scripts/limited-shop-selling.htm

#==========================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts and the SDK if you're using it.
#
# Have problems? Official topic:
#   http://forums.gamebaker.com/showthread.php?t=146
#
#==========================================================================

begin
  SDK.log('SG Limited Shop Selling', 'sandgolem', 3, '26.04.06')
  if SDK.state('SG Limited Shop Selling') != true
    @sg_limshopsell_disabled = true
  end
  rescue
end

if !@sg_limshopsell_disabled
#--------------------------------------------------------------------------

class Game_Party
  def sg_limited_shop_start
    if $sg_doesntbuy_weapon or $sg_onlybuys_weapon
      @sg_limsell_weapons = @weapons.clone
      @weapons = {}
      if $sg_onlybuys_weapon
        for i in 0...$sg_onlybuys_weapon.size
          if @sg_limsell_weapons[$sg_onlybuys_weapon[i]] != nil
            @weapons[$sg_onlybuys_weapon[i]] =
            @sg_limsell_weapons[$sg_onlybuys_weapon[i]]
          end
        end
      end
    end
    if $sg_doesntbuy_armor or $sg_onlybuys_armor
      @sg_limsell_armors = @armors.clone
      @armors = {}
      if $sg_onlybuys_armor
        for i in 0...$sg_onlybuys_armor.size
          if @sg_limsell_armors[$sg_onlybuys_armor[i]] != nil
            @armors[$sg_onlybuys_armor[i]] =
            @sg_limsell_armors[$sg_onlybuys_armor[i]]
          end
        end
      end
    end
    if $sg_doesntbuy_item or $sg_onlybuys_item
      @sg_limsell_items = @items.clone
      @items = {}
      if $sg_onlybuys_item
        for i in 0...$sg_onlybuys_item.size
          if @sg_limsell_items[$sg_onlybuys_item[i]] != nil
            @items[$sg_onlybuys_item[i]] =
            @sg_limsell_items[$sg_onlybuys_item[i]]
          end
        end
      end
    end
  end

  def sg_limited_shop_end
    if @sg_limsell_weapons
      @weapons = @sg_limsell_weapons.clone
      @sg_limsell_weapons = nil
    end
    if @sg_limsell_armors
      @armors = @sg_limsell_armors.clone
      @sg_limsell_armors = nil
    end
    if @sg_limsell_items
      @items = @sg_limsell_items.clone
      @sg_limsell_items = nil
    end
  end
end

class Window_ShopSell
  alias sandgolem_limshopsell_shopsell_refr refresh
  def refresh
    $game_party.sg_limited_shop_start
    sandgolem_limshopsell_shopsell_refr
    $game_party.sg_limited_shop_end
  end
end

class Scene_Shop
  alias sandgolem_limshopsell_shop_main main 
  def main
    sandgolem_limshopsell_shop_main
    $sg_onlybuys_armor = nil
    $sg_doesntbuy_armor = nil
    $sg_onlybuys_item = nil
    $sg_doesntbuy_item = nil
    $sg_onlybuys_weapon = nil
    $sg_doesntbuy_weapon = nil
  end
end

#--------------------------------------------------------------------------
end


QuoteSimply put it in your game, no assembly required.

To keep a shop from buying certain types of items, use these in a call script right before the shop processing:
$sg_doesntbuy_item = true
$sg_doesntbuy_armor = true
$sg_doesntbuy_weapon = true
To have a shop buy only certain items from that set, use these (not the one for that type above):
$sg_onlybuys_item = [#,#]
$sg_onlybuys_armor = [#,#]
$sg_onlybuys_weapon = [#,#]
Those are arrays, use [#,#,#] and [#,#,#,#,#] to add more items to the list. Replace the #s with the item #'s from the database. Make sure you disable the other types of items from being sold if you want the shop to only buy those items.

You can mix and match them however you want. All of these settings are automatically removed after the shop has been called.

Snailer

I thought he said Rm2k3
That doesnt support scripts..

GhstHawk

Thank you! I was going to go crazy if I had to work around it. It's doable, but it would cost me hours of work.

QuoteI thought he said Rm2k3
That doesnt support scripts..

Nope. I said that they had the option built into the editor in RM2K3. I'm using XP.
Secret of the Summit: [Working Title]
Scripts: nearly complete (need skill shop)
Storyline: complete
Database: 50%
Game Progress: 10%


italianstal1ion

Quote from: GhstHawk on December 30, 2006, 04:09:21 PM
Thank you! I was going to go crazy if I had to work around it. It's doable, but it would cost me hours of work.

no problem, glad I could help  :) ^-^ :) ^-^