certain merchants can only be sold certain types of items?

i want to have it so that merchants that only sell X type of item can only by sold X type of item in return, ie equipment vendor can only be sold equipment, item vendor can only be sold items.
I don't have a lot of experience with it, but I believe VisuStella's items and equips core plugin can do that, and it happens to be one of the freebies. If it doesn't do what you need, I'd search through the master list of plugins and, failing that, post in plugin requests.
i want to have it so that merchants that only sell X type of item can only by sold X type of item in return, ie equipment vendor can only be sold equipment, item vendor can only be sold items.
I'm going to add this as an option to my upcoming limited shop stock plugin if that's cool with you, good idea.
I'm going to add this as an option to my upcoming limited shop stock plugin if that's cool with you, good idea.
cool! itd be nice if you could drop a link here when you finish it then.
cool! itd be nice if you could drop a link here when you finish it then.
I'll be making a topic for it. This won't be in the free version but I'll add it as a premium feature.

It already has a feature where if you sell the NPC an item they have limited stock of, it increases their inventory of it.
I'll be making a topic for it. This won't be in the free version but I'll add it as a premium feature.

It already has a feature where if you sell the NPC an item they have limited stock of, it increases their inventory of it.
i'll keep an eye out for it then. i'd ask for a free copy for giving you the idea but i'm not sure how you'd get it to me
i'll keep an eye out for it then. i'd ask for a free copy for giving you the idea but i'm not sure how you'd get it to me
I'm sure that can be arranged.
I'm sure that can be arranged.
I'd appreciate that, then.
This is kind of a dirty trick. But the function in the core script that enables listed items in the sell window is pretty simple.
JavaScript:
Window_ShopSell.prototype.isEnabled = function(item) {
    return item && item.price > 0;
};

It's basically just a true or false evaluation.
Does this object (item) exist? And is the price >0?
If either of these are false, the item in the list is greyed out and can't be sold.

Since it's only a few lines, what I propose you do is just overwrite this function within your merchant event itself. Copy and paste it as a script block before the Shop Processing Event command.
And then just modify the condition so it also evaluates one of these
&& item.isItem;
&& item.isWeapon;
&& item.isArmor;
Edit (fix):
&& DataManager.isItem(item);
&& DataManager.isWeapon(item)
&& DataManager.isArmor(item)
These are functions that already exist within the core scripts to determine the item type (Item,Weapon,Armor)
So if you put this before the shop processing event command.
JavaScript:
Window_ShopSell.prototype.isEnabled = function(item) {

    return item && item.price > 0 && DataManager.isWeapon(item)

};
Items like Potions would be greyed out because they're not a Weapon Type.

I said this was a dirty trick because it's rewriting the function. And you'll want to copy and paste the original code after the shop process to return the function to normal.
It's not the most...er, elegant way to do things. But I think it's less work than someone making a plugin command.
1647054269849.png

setting it up like this just greys out every item including weapons, what am i doing wrong?
ah. Sorry. I must of gotten the structure wrong because it's returning "undefined"
Here we go,
replace &&item.isWeapon with
&& DataManager.isWeapon(item)

Just tested it. This should work.

Edit:
For anyone else that's interested. While I was inspecting the Object data of (item) I had the thought this could be even more specific. So you could sell items by weapon type.
JavaScript:
&& item.wtypeId == 2
where "2" is the "Sword" weapon type in the Default Database settings.
Similarly there's also armor types => item.etypeId
and item types (Key Item, Hidden a, Hidden b) =>item.itypeId

Of course you can add and name your own properties in the note section of the database like <IDKsomeValue: 000> => item.meta.IDKsomeValue
ah. Sorry. I must of gotten the object structure wrong because it's returning "undefined"
Here we go,
replace &&item.isWeapon with
&& DataManager.isWeapon(item)

Just tested it. This should work.
Works now! Thanks so much.
Hi @coyotecraft , any chance of explaining a bit further how to do the script for specific item by using note tags? I tried this method and it doesn't work. I obviously don't know any scripting...
I was wondering if the note tag option is not possible, can I sell based on Item ID? How would the code look like?

Screenshot 2022-03-14 205728.jpg
Screenshot 2022-03-14 205812.jpg



ah. Sorry. I must of gotten the structure wrong because it's returning "undefined"
Here we go,
replace &&item.isWeapon with
&& DataManager.isWeapon(item)

Just tested it. This should work.

Edit:
For anyone else that's interested. While I was inspecting the Object data of (item) I had the thought this could be even more specific. So you could sell items by weapon type.
JavaScript:
&& item.wtypeId == 2
where "2" is the "Sword" weapon type in the Default Database settings.
Similarly there's also armor types => item.etypeId
and item types (Key Item, Hidden a, Hidden b) =>item.itypeId

Of course you can add and name your own properties in the note section of the database like <IDKsomeValue: 000> => item.meta.IDKsomeValue
ex
@limsoonchiong
&& item.meta.SellOnly
Should work.
😮 I can't believe it was that simple. Thanks.
@limsoonchiong
&& item.meta.SellOnly
Should work.

Original thread: https://forums.rpgmakerweb.com/threads/certain-merchants-can-only-be-sold-certain-types-of-items.145672/