Help With My Gold Systems

I think I understand what you are trying to say but I am not quite sure. So this is what I understand, in essence you have 2 “shop keepers”, 2 separate “stores”, 2 separate lists of “inventory” items that each shop would offer and obviously 2 separate set of “financial books” (your gold system). You want to be able to buy something in shop 1 and not have it affect the gold in shop 2, correct?If that is the case this seems like a very simple fix, depending on your game, I am assuming you have multiple levels to travel between and things need to have permanency between levels like the amount of gold in each shop, then what you need to do is have a variable that stores the amount of “gold” each shop has in the Shop Keeper BP. Then use something like game instance to keep that value consistent between levels, so before you switch levels have each shop keeper update the game instance BP variables about how much gold they each have. So each Shop Keeper BP has 1 variable to store the gold, the game instance has 2 variables to store the gold, one for each shop keeper. Each shop keeper will handle their own finances during the level, prior to switching levels or leaving the shop etc, both will update the game instance about how much gold they currently have. When you move to a new level have the game instance then update the shop keeper BPs about how much gold each should be carrying.

Hi i’m wondering if anyone can help. I am trying to create a gold system for my shop keepers but i am unsure how to go about it “EXACTLY” (i have some ideas).

I already have a Gold system for my main player which works flawless but my shopkeepers gold will be a little more advanced. Bit of background - I have my shop keepers (2 so far) both are from the same blueprint called ShopKeeper BP (copied third person BP) on the most part i have everything working, they are separated by their display name’s Shopkeeper 1 & 2.

I have it so that i can have different items in their shops depending who i am visiting (simply done through if display name equals this use this item list if not use a different list) all works fine.
Obviously this wouldn’t work for the gold system because i need variables to change during runtime and not stay the same throughout like an item list.

The issue i am having is actually separating their gold systems. I can make one system work across both keepers but that means if i buy/sell from one keeper the others gold will change as well and also they both have the same starting gold. Obviously thats not what i want to happen. I am just unsure how exactly to go about making them individuals would it all have to be done with arrays (i am a beginner when it comes to arrays only used a few so far so still getting to grips) or would i have to make separate shop keeper BP’s or would their be another way of doing it?

Any help would be greatly appreciated If you need more info please ask away. thanks

First, let’s not open up new “answers” since we are still trying to figure stuff out, use the “comments” button to keep things organized. Second, I think you are missing the point. It is very hard to follow your “setup” and the screen shots you provided aren’t even part of the problem as you state. Your issue is with the shop keepers maintaining an accurate reflection of their gold stores yet you only screen shot the player stuff which is already working. Third, having this be an “open map” game makes this easier not harder, since there is no level transition all your game data will be present all the time until you quit. Fourth, the real issue here is keeping gold stores separate between 2 blueprints of the same class. This is not hard at all since you will have created 2 instances of the blueprint. Each instance can store its own value for the amount of gold it is carrying. As long as the “Shop Keeper BP” has a variable for “gold” you can change them independently. If you buy from shop 1, add X amount of gold to that shop BP’s gold variable. If you sell to shop 2, subtract X amount from that shop keeper BPs gold variable. They shouldn’t ever be the same when you modify the instance of the BP. What you display in the widget needs to then reflect the shop BP that you are currently interacting with. By pulling the variable from the specific instance of the shop BP you are visiting you should have no problems updating a widget to display this info. What you might be having problems with is how you buy/sell within the shop and how you have set up your widget. Which I assume you have buttons for purchase and sell etc, but if these are not somehow some way grabbing a reference to the particular shop BP instance you are using then you will not have he right values. Without any screen shots of the actual widget implementation, the buy/sell functions etc I can’t tell you where you are going wrong. But from the sound of it this should not be difficult to figure out.

Thankyou for your fast response and while that sounds like a good idea it wouldn’t really work for my project ill try and give better info.

GAME TYPE is a third person open world so no “levels” just the one main map.

My shopkeepers both come from the same Master blueprint copied and pasted in the world so i have 2 of them. In the “world outliner”
i changed their display names from “shopkeeper BP” to “Shopkeeper 1” & “Shopkeeper 2” so i could call them separately in blueprints much easier.

I have a main UMG “Shop widget” as a base then i have separate “offered items” widget. The offered items are controlled through an array of my master items i then obviously select which “Items (array elements)” i add to each array example “Tier 1 Items Array” will contain potion items who i want Shopkeeper 1 to sell.
Ill also have a “Tier 2 Items Array” which would contain weapons i want shopkeeper 2 to sell.

In the shopkeeper BP i run a name check through a “get display name” node example shopkeeper 1 then i check if it is equals to itself “shopkeeper 1”, if it is then i set the “Offered items widget” to use the “Tier 1 items array” and populate the “shop widget” with the potion items. or vice versa. (not exact setup but enough to give rough idea of how its working).
that’s obviously how i have the different items showing between the 2 shops.

the issue im having is doing their financial side of it ill show how my main characters (Third person BP) is set up so you get an idea but the shopkeepers won’t be able to work this same way.

In my Third person BP i have two integer variables “Current Gold” and “Max Gold” (Some pretty high number).
In the “Update gold” Screenshot that takes my current gold value and updates it to my player inventory so my player can see how much they have.

The Screen Shot “Increase Gold” is obviously a function i call in other places when i want the current gold to increase for example if i sell to the shop. when i click the buy button check the value of that item from my “Items struct” then increase the “Current Gold” by that Value then call the update gold function for the player visual to update.

I have the decrease gold function that obviously does the opposite to the above.

Thats how my player gold works simple but effective.

I cant however use this for the shopkeepers because i want them to start with different amounts each say 5,000 for shopkeeper 1 and 10,000 for shopkeeper 2.
if i make 2 integers called shopkeeper 1 gold and 2 or the other set their default value to their respective amount if i place them in the update gold function then any time they are called they reset back to the start values.

the closest i have got to making it work i was able to get them to start with their respective amounts i can go into one shop buy from them and increase their gold amount but as soon as close the shop then open it again or the other one their amounts are reset back to the 5,000 and 10,000. i’ve been racking my brain but cant think of a way around it.

sorry if this is long winded and confused you more but i hope its helped lol

Sorry for posting last comment as an answer but it was the only way it would let me post. Kept saying i had exceeded the character limit for it to be posted as a comment. also sorry for the delayed reply but i have now solved my issue although it wasn’t as straight forward as you put it. I couldn’t call and change variables between my shopkeeper BP and my offered items due to them being called in other blueprints.

My first mistake was trying to do everything inside just one shopkeeper BP and creating copies of them and trying to split them inside the same blueprint. I had to change it to be more like my items and have a master shopkeeper BP then create the child BP’s from that. this enabled me to give them starting gold values separately. Then to change the values i had to set it up in my third person BP and do cast to the shopkeeper to enable me to change variables as wouldn’t let me do it directly.
bit more complex than that but general jist of it. If anyone would like to see how i solved it i would be happy to help and go into greater detail though will take a little while to tidy things up and take screen shots.