Correct way to handle server "while busy" check in Blueprints

What you can do, for a more direct approach, is use server and client events to set the busy status.

  • Client clicks card via trace
  • Client tells server it has clicked the card
  • Server sends an event back, ‘click success’ (set busy on client) or ‘click failure’ (warning)
  • If success, server deals with click
  • Servers finishes, sends ‘your turn’ (or whatever) (unset busy on client) event back to client

These need to be reliable events. Relying no replicated bools isn’t a good idea. They may be replicated slowly and inconsistently.

I’m implementing a card game and need help determining when the server is “busy” on the client.

The turn of events is first the client clicks on their deck (through a line trace), calls a server event which draws a card, and once the event is complete then the client can repeat the action. Of course, if the client clicks before the drawing event is finished, then nothing happens.

Here is the best logic I could think of:

  1. Through a trace hit on the client side, the client clicks the deck.
  2. The client’s “busy” variable (not replicated) is set to true.
  3. The client calls a server event where the “busy” replicated variable is set to true.
  4. In the server event, the client “busy” variable is set to false.
  5. When the server event is finished, the “busy” replicated variable is set to false.
  6. The client’s trace hit can now fire again since both variables are set to false.

Is this the best way? I’m sorry if I’m simplifying this too much, but I just need the basic framework of a client to server event where the client can’t continue until the server is finished.

Any feedback is appreciated. Thanks!

That’s correct, yes.

A slightly better way would be to set the busy flag when sending the initial event to the server, rather than waiting for a response. Then the click failure event removes the busy flag.

Yeah, I was having that problem with using replicated variables. So when the client tells the server it has clicked a card, that’s an event, right?

Awesome, I’ll try this out. Thanks for your help!

Where is the busy flag stored? In the character blueprint that is using the trace or in the game state, perhaps? And if it needs to be replicated, then that seems like the same issue as earlier.

You don’t need to replicate it. The server/client events deal with that. Store it wherever you like. Wherever makes sense for you. I will say, putting it on your character, player state or controller will make it easier to deal with events. Those are the only 3 objects you can send server events on.