#Delaying a command until all clients are connected

8 messages · Page 1 of 1 (latest)

vale grove
#

Hi everyone. I need some help with what may be a very simple question, but I've been troubleshooting for days and coming up blank.

I've developing a two-player card game and I want the server to deal cards only once both players are connected.

Using the NetworkManagerHUD, I can begin the game by selecting Host+Client and that appropriately spawns the PlayerManager (the Player prefab for connected Clients) and deals cards to the Host through the use of CmdDealCards in an override of OnStartClient in the PlayerManager script. However, I'd like to delay this action until the second player joins, upon when the server will deal cards to both players. Is there an easy way to implement this check?

Again, apologies if this is a very simple question, but I've been at it for days and I'm starting to lose hope.

Thanks in advance!

tender ibex
#

Maybe make the network manager track the amount of players in the lobby

#

Using an int

#

And then only execute the command in OnStartClient once the int is already the desired number?

#

That should work i think

boreal plume
#

Personally i use an isReady variable, set by clients OnStartLocalPlayer
Server cycles through all connected players and see’s if they’re all ‘ready’.

#

@vale grove