I’m currently working on an inventory system, finished all of the server-sided scripting, and starting on the local side ones.
I see four options of handling the local side:
Send the new inventory table and re setup every slot that is not empty.
Send the amount to add or remove, and only setup the slots needed to be edited.
Send the new inventory table, compare it with the local one, and re setup only changed slots.
Send a table with only the slots to change, and re setup only these slots.
The question is: Which of these 4 options are the best to go with?
Note that the game is an MMORPG so inventory slots change a lot during game play.
Option 3 seems to be straightforward to implement and not prone to displaying the wrong data to the player. Updating every slot (option 1) isn’t neccessary. But since you’ll most likely only change a couple of GUI objects whenever the inventory updates, which (due to the nature of an inventory system) won’t happen very often, I wouldn’t worry about this type of optimization.
Your server scripts will be validating each inventory action and storing them in the players inventory table already. Simply sending that table over the network shouldn’t be too much of an issue as long as you’re not sending 100+ objects. And even though you say the inventory will change a lot because it is a RPG game, I really dont think it will be that much from a networking perspective compared to all your other systems for NPC’s, weapons, streaming the world, and server-side anti-cheat.
Optimizing systems to run as efficiently as possible on clients is great for things that require frequent updates or cross-player-synchronization where every frame counts. But for an inventory system? Nah.
Option 4 is the most network efficient. It doesn’t hurt to slowly resync each slot either if you want reliability. For example, update a few slots every second. This will spread out how much data you send and prevent throttling.