Jump to content

Multiplayer


Slimwaffle
 Share

Recommended Posts

Hey guys.

I am just wondering how multiplayer code actually works.

So I want to make it so one person can host. Their game does all the loading of trees and enemies and such and does all the saving.

So I saw a post about sending messages from player to host.

Does this mean I have to send player position and health and so on to server?

What would a message sending player health actually look like?

And do I have to do this for every single thing that happens(bullets, damage, inventory, position e.t.c)?

And do I have to send all the game info from host back to client?

Link to comment
Share on other sites

Hi

 

Have a look at this article is informative:

https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization

Client  --- request ---> Server

Client <--- response --- Server

 

Text protocols:

For example json, packet to send over network:

{"TypeId": 5, "Payload":"{}"}\n

End of line character tell when the packet is finished.

TypeId is used to identify packets. In Payload can be any json object with the info you want to send.

Client will send this packets to the server for example TypeId 5 could mean update inventory for the game, or something else update hit points for this client.

  {"TypeId": 0, "Payload":"{}"} could be an response ok message. If everything went ok the server will send this to the sender of the initial request.

This is just example to give you an idea.Can use any text format you like.

 

Binary protocol:

Usually binary protocols are used for efficiency reason (less data sent on network).

A packet has a header and payload.The header contain the size of the package and other information.Payload contain the real information to be sent.

Here is an real life protocol i found , you would need something much simpler.

https://github.com/couchbase/memcached/blob/master/docs/BinaryProtocol.md

 

 

Its a broad topic just trying to give some hints.


 

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...