Jump to content

Syncing Mod Data on Items to Other Clients?


robob27

Recommended Posts

I am trying to write a shopping list mod and am having trouble with a key piece. I already have the recipe, UI for editing the list etc complete, but when I was testing with a friend we noticed that when I made changes to a list after it was created he was not able to see the updates. I started looking into sendClientCommand and sendServerCommand and was able to successfully pass my playerIndex to the server, and have the server send a message back to the client.. but I can't for the life of me figure out how to tell the server to update the mod data on the specific item I just updated on the client since sendClientCommand won't accept complex inputs like an InventoryItem. Anything I can think of seems like it would be prone to not working 100% of the time. Like if I were to make sure the item was on the player first (not ideal) and then find it by name, type, category, there are possibilities for the wrong list to be updated. There seems to be quite a few methods around transmitting mod data, but none of them seem to work with an InventoryItem, and I can't find any ways to convert an InventoryItem into something that has any of the mod data transmission methods either.

 

Is this possible to do or am I chasing a unicorn here?

Edited by robob27
Link to comment
Share on other sites

Hi robob27. The only thing I can think at top of my head, is if the inventory item has an id, that will be synched from server to clients. and then pass that id as an argument, and then loop through the player's inventory on server.  

 

 

I was working with both functions recently, and I noticed that sendServerCommand with player object passed into it to target a player, does not work.  I had to use sendServerCommand w.o. player and broadcast, and send the player number I cared about in the arguments, and then on the clients compare that with the client player num. 

Link to comment
Share on other sites

Thanks for your reply! I did try to find some sort of unique ID property on items, but I wasn't able to find anything built in.. thinking about it again though.. perhaps I could set some sort of unique identifier on the Shopping List at creation myself, store it in mod data, and then server side I could use the unique ID in the mod data/playerIndex to lookup the item :-o

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...