Advice on workflow - Hintsystem - Problem

Okay so I have been working on a hint system for our game for a while and I am at the end of having everything working. One issue I have now is that the clients can’t buy the hints in a predictable way.

I was trying to figure out a good place to store the number “hint charges” that players would find in the game. These would have to follow on level changes and stay synced and correct. My solution is to have the number of charges stored in the “ObjectivesTracker” blueprint and in the game instance. On begin play the BP syncs the number of charges from the servers game instance.

The reason why I did it like this is to be able to see the number of remaining hint charges in the widget.

I have a function inside the objective tracker that returns the hint when purchased and subtracts a charge from the local sum of charges and syncs it to the game instance.

This all works fine on the server but when the client buys a hint it does not get subtracted and the hint isn’t available to the server or any other client.

Both the sum of hint charges and the array are set to replicate.

Ive tried a lot of different things but nothing seems to solve this. Does anyone have any suggestions?

Well if it’s calling from the widget you’re calling on the client. What you want to do is calling a server event on the objectives tracker so it’s the server that deals with it, and then it can send the hint or whatever to the client. See this custom event here

I set the replicates to Run on Server

There’s also other replicate methods, and you’d probably use a multicast one to say that a client has purchased something (to all the other clients)

1 Like

Thanks alot for the reply!

Yeah exactly I want to call a server event on the BP but just calling a server event from the widget inside the BP does not work. Not sure how to make the client call the server event inside the tracker …

Any ideas? :slight_smile:

So here is how I solved it if anyone has similar problem:

  1. Widget button event triggers a call to the player controller “Server purchase hint”, pass on a reference to the objectives tracker.
  2. The Player controller event is set to “run on server” and triggers the purchase function on the objectives tracker.

Not the clean solution I was hoping for but works.