Saving inventory in multiplayer not working

mb the print string was badly coded and was returning incorrect answers

so the one who is returning 2 as last index is the server and has 3 items, meaning that its items got saved correctly.
the one who is returning empty is the client and has 2 items, meaning that the items arent replicating correctly. Any solution to this?

saving/loading is only done on server so it cant be a replication issue. make sure the actors are valid.

you’re using getallactors so if the client isnt loaded yet it will fail but thats just an example/guess

both are valid
Captura de pantalla 2024-03-19 132606

ill need to see more of your code but looking back just want to confirm your additems is run on server yeah? if the client updates it, it will still be empty on server when you save

ik some screenshots are unnecessary but here is the entire code just in case
Player Character:



Captura de pantalla 2024-03-19 155002

Blueprint Function Library


Inventory Widget

Player Controller BeginPlay

i dont see what calls your add item, but your remove item is running on client so i assume your add item is too. this wont work.

what you need is a server RPC on the player.

all you need to do is create an event on the player call Server_AddItem, mark it as runonserver. connect it to your already made additem function passing through the index. call the server function from the widget.

that said id highly recommend you make an inventory actor component and do everything in there. then pass the inventory through to the widgets on construct and they can bind to inventory updates too

omfg its finally working thank you so much :sob:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.