Shopkeeper Dialogue Different if you Buy

Is there a way to tell whether you bought or didn't buy something at a shop if you use shop processing?  I'd like this so that the shopkeeper would say something if you: didn't buy anything, didn't have enough money, or bought a particular item.  I know you could do it with switches if it was a one of a kind item, but what if it's not. 
It should all be quite possible with variables set before and after the shop processing as well as condition branches.


Set Variable [before] -> Game Data / Gold or Game Data / Item in inventory


Shop Processing


Set Variable [After] -> Same as before.


Conditional branch comparing Before and After and changing the dialogue based on which circumstances you want. You can set multiple before and after variables if you want to check for various things at the same time.
That's probably the easiest way, but not the most accurate.

If you have more gold after the shop screen, it could indicate that you only sold something, or it could be that you bought something and sold something, and the item you sold was worth more than the item you bought.

If you have less gold after the shop screen, it could indicate that you only bought something, or it could be that you both bought and sold, and that the item you bought was worth more than the gold you got from selling.

If you have the same amount after the shop screen, it could indicate that you didn't buy or sell anything, or that you both bought and sold, for the same amount.

To be certain, you'd have to allocate switches which would be turned off at the beginning of the shop screen, then turned on after a buy or sell transaction, and you'd have to check the switches afterwards. I'm sure it wouldn't be too difficult to make something like that.

Edit: In fact, here you go. Make sure you change the 1 and 2 for the switch numbers on the first couple of lines, and preferably name those switches so you don't accidentally use them for anything else.

Spoiler
Code:
class Scene_Shop < Scene_MenuBase  #--------------------------------------------------------------------------  # Set the following constants to the id of the switches that will be turned  # on after buying and selling  #--------------------------------------------------------------------------  BUY_SWITCH = 1  SELL_SWITCH = 2  #--------------------------------------------------------------------------  # * Prepare  #--------------------------------------------------------------------------  alias shaz_shop_notice_prepare prepare  def prepare(goods, purchase_only)    shaz_shop_notice_prepare(goods, purchase_only)    $game_switches[BUY_SWITCH] = false    $game_switches[SELL_SWITCH] = false  end  #--------------------------------------------------------------------------  # * Execute Purchase  #--------------------------------------------------------------------------  alias shaz_shop_notice_do_buy do_buy  def do_buy(number)    shaz_shop_notice_do_buy(number)    $game_switches[BUY_SWITCH] = true  end  #--------------------------------------------------------------------------  # * Execute Sale  #--------------------------------------------------------------------------  alias shaz_shop_notice_do_sell do_sell  def do_sell(number)    shaz_shop_notice_do_sell(number)    $game_switches[SELL_SWITCH] = true  endend
Is there a way to tell whether you bought or didn't buy something at a shop if you use shop processing?  I'd like this so that the shopkeeper would say something if you: didn't buy anything, didn't have enough money, or bought a particular item. 
hello there, you already made this same thread days ago and Shaz already answered your question...

http://forums.rpgmakerweb.com/index.php?/topic/19257-shopkeeper-dialogue-different-if-you-buy/
Merged. Please stick with a single thread for your issue, since the two are closely related.


If you want to know if they bought a particular item, you would have to use Rachael's original suggestion - put the number of those items on hand into a variable, do the shop processing, put the number of those items on hand into a second variable, then compare the two.


The "didn't have enough money" is more complicated, since a shop can stock half a dozen different items, and you might be able to afford 3 of them, but the developer would have no way of knowing which of the 6 items the player might WANT to purchase, and they could ATTEMPT to buy the other 3 items and get the buzzer, so a "didn't have enough money" wouldn't specify a particular item either.


If it's a shopkeeper with only one item and you want a different message if they don't have enough money, I just skip the shop processing altogether, have the NPC ask if you'd like the item, and add conditional branches and choices depending on whether there's enough money or not.
hello there, you already made this same thread days ago and Shaz already answered your question...

http://forums.rpgmakerweb.com/index.php?/topic/19257-shopkeeper-dialogue-different-if-you-buy/
Huh.  I only posted this topic once as far as I know.  That link is to the exact same page.
Because I merged the two threads (as indicated by my saying "Merged" 😉 ).


Post 1 and post 4 are yours, asking pretty much the same question. You still haven't said if the script I provided less than half an hour after you originally asked, does the job or not.
You still haven't said if the script I provided, does the job or not.
Sorry I know I'm way late, life got busy for awhile and I forgot to answer this.  The script works and will be useful.  I did want it to do 2 more things though.  Check what specific items you bought or sold, and also if you try to buy something too expensive set a switch and exit shop processing with the ability to enable and disable this.  If keeping track of all items bought and sold is too much then maybe just checking if a particular item has been bought or a particular one sold.  I don't know how much is actually possible in RM, so I may not know what I'm asking.
Hellooow 2014, I'm writing from 2020, almost 2021... btw

I'm lurking the forum but I never posted before... I know that in the Shaz code here I probably can find a solution to my recent problems in my game.

But I can't understand how to use it

I copy pasted in a script call in the event vendor and isn't working, I've tried to put it in a single script line, then I tought that maybe the # could let all the script be seen as comment, so I tried to respect the rows... I've tried to eliminate all the comments. Still not working. I'm also very concerned about some part of the script that says (number) i'm supposed to copy like that or put a number in it instead of the word number? Is like when there is a form with name and second name and I write "name" and "second name" insted of my name...
I've changed the number of the switches and I've created and named the switches in my game... I'm so lost...

Let me explain my problem. "The noob vendor"
In my game there is a vendor that is a noob vendor and doesn't know the price of things, is possible to buy an item for 50 gold and sell them back to the vendor at 200 gold, basically generating money out of thin air. But... when the shop processing is over (it would be better during it, for exemple when the player reached certain ammount of money, but I don't care much about it) the noob vendor realizes she/he is been scammed, and after a cutscene, from that point forward the noob vendor will disable the sell option for being sure the player doesn't scam the vendor anymore. (The player can still buy the wrongly priced item from the noob vendor and sell it to other vendors without any problem and is what I want)

So i've created a variable to store the gold the player has at the beginning of the shop processing, then i check the gold the player has after. And I've branched if the player has more money, the same ammount of money or less money... but as Shaz said in this 2013 post... is a very uncomplete script, it works most of the times, but if the player comes and sell an item found elsewere the math will tell he did the scam so this isn't helpful at all. I even would like to know if the player abused the wrongly priced item.

Can anyone help me?

It would be super awesome also to find a way to turn a switch on if the player sold more than 99 wrongly priced items becose if the player choses to abuse that, will probably buy 99 and sell 99 many times untill the player is satisfy with his/hers gold ammount. But the player can choose to sell all the wrongly priced item before finishing the shop processing so a check if the player has that item in inventory is useless.

Untill I find a better way I made a check on how much gold the player has before shopping and then confront the ammount of gold the player has after, if the subtraction is significant, like 30k gold the cutscene happen.

Thanks in advance, and I hope I'm posting in the right place... I think my "problem" is very much related to this topic even if is an old one.

@Zako , please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


I believe you're better off starting a new thread.

Original thread: https://forums.rpgmakerweb.com/threads/shopkeeper-dialogue-different-if-you-buy.19257/