Slimwaffle Posted September 26, 2018 Share Posted September 26, 2018 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? Quote Link to comment Share on other sites More sharing options...
aiaf Posted September 26, 2018 Share Posted September 26, 2018 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. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Slimwaffle Posted September 26, 2018 Author Share Posted September 26, 2018 Is the code going to look the same if my game was built using lua? Quote Link to comment Share on other sites More sharing options...
aiaf Posted September 27, 2018 Share Posted September 27, 2018 You can use same protocol , but probably code will be different in lua depending on what you use (luasocket maybe). I think leadwerks will have an easy to use multiplayer system.But not out yet. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Recommended Posts
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.