• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Prevent item dissapear from market

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,853
Hello, in my map I have item shops that sells items that depend on gamemodes, to add/remove them I use the function AddItemToStock and RemoveItemFromStock, the problem is once I buy the item, it dissapears from the shop and I can buy it again, how can I solve this?
 
Level 18
Joined
Oct 17, 2012
Messages
822
Hello, I'm having issues with my shop system. I want to re-stock an item whenever you purchase it from a shop. I figured something like this was sure to work:

  • Purchase an Item
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Neutral Building - Add (Item-type of (Sold Item)) to (Selling unit) with 1 in stock and a max stock of 1
This causes problems. Yes, the item is added back to the shop, however, after purchasing my 2nd or 3rd item something strange begins to happen. The item to the right of my purchased item disappears. Then from that point on it continues to do so with every single purchase I make. I think it has something to do with the fact that when I add the sold item back to the shop it's replacing the position of the item that WAS to the right of it. Seeing as how the button positions automatically update and move when you remove an item, I imagine this is the problem.

One solution I found was to remove all of the items from the shop, and then add all of them back. However, this has the unwanted side effect of refreshing the Stock Interval of every single item.

EDIT:
Found the solution!
Add these two custom scripts to your map initialization. I'm not sure if these cause problems with anything, so just a word of warning. Although, I tested it in singleplayer and everything seemed fine. All it appears to do is prevent items from being permanently removed from your shops. This could cause issues I imagine, depending on what you're trying to accomplish. You can probably find a workaround or turn these on and off to get what you need.

  • Shop Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call PauseTimer(bj_stockUpdateTimer)
      • Custom script: call DisableTrigger(bj_stockItemPurchased)
 
Status
Not open for further replies.
Top