   Networking and Games :: Sending Information From Other Players
  Okay, so I am working on a 3D engine using DirectX (D3D) 9. It isn't too far along. But I also plan on writing my own little networking library, to add multi-player functionality to my engine.My question is -- if I have a simple level for two players (ONLY the width/height of the screen; no scrolling, etc.) how do I send updated player positions, etc.? I mean, do I send them each time they move? The level won't go past the boundaries of the screen. Each player is a simple character (3D model). If I already know what character each player is using, how do I send updates?Also, how do I send messages? And I don't mean in general. I need to know if I each client sends to the server, and the server sends the data to both clients. Or if the host's client updates itself, and just sends/receives data to get info. about the other player.I hope this is clear enough. I'm sort of in a hurry. I just got home from work, and I may go to bed soon. I don't know yet -- it's Friday, so I want to enjoy the weekend. =PThanks in advance,    Matt U.   
  The client does not ever send it's location to the server.  What the client does is send a "move request" to the sever.  The server then sends the move to everyone that can "see" that move.  The clients then move the char to the location.  The reason you do this is because you should never "trust" the client.  The server needs to verify that it is a legal move before the server allows it.  This will prevent teloport cheats (for the most part).  Anything to client wants to do should be sent as a request to the server and then after verified sent to the clients.  You send the results of the request to the clients not the request itself.  So if the move is illegal you would either not send anything or send the same location, if the move is legal you send the new location.  Just a suggestion, add in code about "seeing" the other player.  This is good practice for more complicated multiplayer games in which you have more players.theTroll   ;  Okay, I think I understand what you're saying. And it makes sense. =)But do you mean that even the client on the host's computer should first send a move request, then move when it gets a response from the server? Or does the individual client move/update as it would if it was in a single-player game? I think that's clear enough. If not, I apologize. =)Thanks a lot though. =)   ;  If it is multiplayer and the client and server are on the same machine you still treat it as if the server is on a remote machine.  This will prevent the local client from doing simple cheats.  So the local client will send a move request to the local server, the server will then respond and tell the client where his move put him.  Now is that kind of a waste of processing power and network traffic, why yes it is, but it makes your code simplier because everyone uses the same methods to do things and it also makes it a little harder to cheat.theTroll   ;  Thanks much for the info. =)   ;  hehe troll and his cheatofobia :pThere are many different solutions, some just basicly send a client's keyboard state, when a key goes down the server gets notified and when it goes up it gets notified again. You probably don't want to send it immediatly because that could congest the connection too much, so send these updates at a fixed rate like every 50ms.Keyboard status itself is not enough, after a while players would be on totally different positions on each client, so there will be need for somekind of position update too.You will also need to synchronize your clients with the server. For example the server sends a timestamp with each update. Once an update arrived, each client tries to calculate how long it took and then advances this object to a new position.It's pretty basic but the best thing is probably to just play around with it, once you get it working you could start thinking about more interesting methods that could benefit your game.   ;Quote:Original post by ronkfistKeyboard status itself is not enough, after a while players would be on totally different positions on each client, so there will be need for somekind of position update too.How about this:-clients only send the server their key press/release events-the server sends every client the full position list (with every object) every N msecViktor