Multiplayer Inventory System

Hello, I’m building a replicated inventory system with a dedicated server but I have some questions about how to manage it…

The players Slots are stored on the server and then replicated to the concerned Client. Then a simple inventory widget show them. Player can reorder Slots using drag&drop.

I would like to know if i should avoid Multiple Server request from the players (swapping slots) to reduce the data consumption of the server or is it insignificant? I have 0 knowledges and experience on data cost on a Dedicated server and i have no idea how big are these data when the player simply swap a Slot (basically just a SwapElement function).

So I made a second array (not replicated) for managing Slots reordering without having to reorder the Slots Stored on the Server but it begin to be a pain to handle… I would like to use only one Array stored on the server, is it a good idea or should i keep this system?

As a disclaimer, I don’t have too much experience with networking when it comes specifically to games, but my thought is that this shouldn’t be a concern.

The main reason is that the inventory system is not a large function of the game.

  1. Traffic is only sent between server and client when an item is swapped, which isn’t as often as, say, shooting a gun or running around.
  2. This would likely be event-based, instead of continuous streaming. The server and client would only need to talk when a player swaps an item, which doesn’t happen often.

Thank you for your answer. And for things like “sort alphabetically” or “sort by weight” (can sort more than 100+ item per player), should i handle this also on server?
I can also execute the “Sort” function only on the client and then Set the Server_Array by the result of this function (with some check to see if items are valid on server).
Is it necessary or a lost of time?

If the reorder is not simply a convenience for the player then it should be replicated from the server otherwise it would allow the client to cheat. If it is purely a visual reorder then it makes sense to simply reorder on the client.


The frequency of the request, the datatype (Bool is best while Text is one of the worst), and if it has changed or not is what determines how expensive it is to send from the server. You also have to consider the latency if the server needs to verify your request so if it can be handled locally then it is often the best way of doing it.


If you are familiar with the Model View Controller pattern (MVC) then the Model (data) should be replicated and the View (Widget) should handle representing that data in whatever fashion the user wants it to be. The Controller would be split into validated (RunOnServer) events and non-validated local events that just change the appearance (perhaps order) of the Widgets.

Sorry for the late reply, but those sorts also shouldn’t be that big of an issue, following the same points as the swap. Doesn’t happen too often and isn’t a very expensive function.

Having the server handle the sort and spitting the result back to the client should be fine though. Also helps with data security, if that ever becomes a concern for you.

You can test the network performance using the Network Profiler to see how expensive it is rather than guessing.

Hello,

To give you an answer on your question:

First sorting by alpha weight etc haven t to be on the server only on the client who want this feature same thing if you plan to make a search bar systhem.

For your previous question it s depending on the fact if others players must have the same order as the player who made swap.

i hope this answer help you in some way.