O'Reilly logo

Torque 3D Game Development Cookbook by David Wyand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to access all client connections from the server

During a game, we often need to work with all the connected clients at once, such as sending out a game update. In this recipe, we will learn how to go through the list of all the connected clients and do something with them.

How to do it...

The ClientGroup collection is a SimGroup collection that stores each of the client's GameConnection instances on the server. The easiest method of stepping through this group and working with each connection instance is through the TorqueScript foreach() operator:

// Step through each client in the ClientGroup on the server foreach(%client in ClientGroup) { // Play a thunder clap sound on the client. The play2D() // method sends a network sound event to the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required