Download

Creating Widgets on other Clients screens?

Hi, what would be the best way to open a widget on someone else’s screen? I’m trying to make it so when you interact with another player, it pops a notification up on their screen saying you’ve requested to trade, and if they click yes then it will open a trade widget for each player, but I can’t figure it out. I’ve tried to call a function from their character reference that adds the widget, but it adds it to your own screen. I even tried calling a server event, that calls a multicast event, that calls an owning client event to open the widget from their own HUD reference (there’s an event in the HUD class that creates the widget), among different combinations, but nothing works

Event Dispatcher would be the way I’d go. Get a player identifier (unique id of some sort), pass that to the dispatcher. On the listening end compare the identifier. if == proceed.

After further thought … BP Interface, communicating directly to the other party with the an interface makes more sense.

Actor Component (Trading System), Interface calls functions within it.

I’ve tried this so far, but it’s not opening the trade request widget, I’m pretty sure it’s because I’m calling the event in the other player’s pawn’s component on my game instance, because it’s trying to call the Open Trade Request event from the HUD reference, which is coming back with an error saying it doesn’t exist (“Accessed None trying to read property HUD.”), and it wouldn’t exist if it’s not the locally controlled pawn. How would I call it in the component on their pawn in their game instance?

No time atm but a quick gut reaction says that an interface call on its own won’t fix this. Its going to require a ‘Run On Owning Client’ RPC for that one specific target player imo. Or an Interface call that gets run on every Client, but only executes for the local player that needs to see the widget.:wink:

Consider a Listen-Server setup with 2 Clients. That’s 3 different local players. But actually 9 different instances of those players. For which you need to execute widget code for only 1 of 9. Overall, the Client requesting trade, needs to execute an RPC to the Server passing some kind of reference to the ‘target Client’ (the one that needs to show the widget). The Server then executes ‘Run On Owning Client’ using that reference. Afterwards, the ‘Run On Owning Client’ event gets run only on that one Client that then shows the widget.

The other method, is to replicate a variable (repnotify). Again the one requesting trade, sends an RPC to the Server. The variable could be a struct or something like A. a reference to the trader (the one sending the trade invite), B. the type of item to trade, and C. the ‘target Client’ to get or receive the widget creation message. The Server then updates the replicated variable with all that info, which forces a repnotify to all players. In each player’s repnotify function, code is then executed to determine if they are the ‘target Client’, and if so, only they show the widget. So a multicast isn’t even needed iirc. This postmight also be of interest to help branch code between Local vs Remote Client… :wink:

@Mikester4411 This ^^^^

The interface is used to determine interaction. The Who aspect. From there you maintain client-server model. RPC server (WHO, you want to trade with). Server RPC’s the WHO client (run on owning client). They confirm/deny and you go from there.


In your example you’re interacting with the local proxy of the player… Not their local instance.

Sorry, hadn’t had chance to try until today.

I’ve tried to go for the RPC route, but I’m still fairly new to replication, I’ve got this but only the first break point is triggering, for some reason it’s not calling the Server event at all.