Multiplayer inventory lag

Hi there, I am slowly developing a multi-player game. For this I need each player to have their own inventory, which I store on the server (to prevent cheating).

The problem is, it looks like there’s considerable lag when updating the inventory, so much so that swapping items in a client connected inventory takes a movement and is very noticeable to the player. Also this is causing synchronisation issues with other elements of the code, as when they run they still see the older non-updated inventory for a moment.

What is the best way to code a multi-player inventory ?

Would it be an replicated array of actors (which themselves replicate - is this the cause of the lag ?)

Or an array of Uobjects (which don’t replicate), but which is only read / written on the server ?

  • in which case how do return values from the server to the client (in order to show the inv on their screen) when the only way to run a trigger a function from the client to run on the server is an event, and events don’t return values.

How have other people done this ?

You need to minimize amount of data sent. So update only when it is needed and only what is needed.

For that create some function that calculates checksum like CRC32 (you should do it in c++)
Let server and client manipulate inventory. Then client should send over only CRC32 of inventory, and server compares, if there is mismatch server forces update on client.

Nawrot
Found this:
“Static arrays are sent over the network efficiently by only sending the changed values. This rule however is overridden if the static array is within a struct, due to the “all or nothing” rule attached to structs. Thus avoid large static arrays within structs, as then the entire struct is sent even if a single array value is changed.”

Ahhhh OK I have my array in a struct… so the whole thing is being replicated.
Even so we are only talking 12 items (currently actors), surely that shouldn’t be taking .5 of a second, should it ?