Game Development Community

Server and Client

by Garth Wood · in Torque Game Engine · 04/28/2006 (4:08 pm) · 2 replies

Hi

This is a general question. How does the whole client and server thing work? Why is it that the game scripts such as the crossbow etc are on the server and not the client? Surely the server should just serve as a connection and the client hold all the data?

Apart from that, I'm a bit confused as where to send commands. I was trying to get throwing of an object working just buy getting the controlling object in the client default bindings and then stumbled across a tutorial that used serverCmd... and it worked.

So when do I send a command to the client and when to the server? I think what i really want to know is, what is going to update what.

Thanks

#1
04/28/2006 (5:05 pm)
If you held all the data on the client, then it would make cheating very easy, as players could tell the game to do whatever they wanted. This way it keeps everything in sync and fair between the players. All of the data is sent from the server to the clients for them to actually use of course, when you see the "loading datablocks" phase of mission loading. This is known as "ghosting", as the objects then exist both on the client and server, with the server version holding authority. In general, you only use clientCmd / CommandToClient to modify GUI elements, because these are supposed to be unique for each player, and irrelevant to other players. serverCmd / CommandToServer allows the client to request the server to do something.

Things like movement and firing already have C++ functionality using the MoveManager, but anything else that needs to interact between all the possible players in the game world needs to be sent as a CommandToServer (assuming you only want to use script). You've seen the example where it's needed to change the control client, because _all_ the other players would need to know this data to see things properly. Even with a single player game, the client/server model is so intrinsic to how TGE is setup, it's best you just learn to work with it.
#2
06/30/2009 (4:39 am)
thnks dear!