Hello and thank you in advance for any help you can provide me.
Currently I am trying to create an Inventory system. The system is held on the server and replicated to the client to prevent hacking and allow interactions to be server authorized. This is also hosted in Player State so that it persists.
Dealing with Inventory means I have variables stored in structures and placed into an Inventory Array. When I attempt to resize the array on the server using a Run On Server RPC or Begin Play event my standalone dedicated server crashes and I get disconnected.
The same is not true if everything is either run on client or Switch on Authority to remote.
The act of resizing the array on the server is the cause of the problem.
If I am doing this wrong or if anyone has any suggestions I would be forever grateful.
The first two images causes the pawn to not spawn
The third works fine but is not handled server side and is not safe to use
can you share your code/bp to see how you do it? What are the error messages in your log?
Sorry, I can’t reproduce it. Don’t you get any logs? How do you run your dedicated server? I’ve created a boolArray which is replicated and is resized on beginPlay. Run my game in dedicated mode (-server -game -log) and join with a client - all works like expected. But I’m on 4.23 already, maybe this makes a difference or the type of variable you put as array? try to change it for testing - boolArray worked for me
Alright so i tested resizing a boolArray and it succeeded, everything loaded fine. Inside of the Inventory Array I have an Item Info Structures. Inside of Item Info Structure I have an inventory index integer, a unique item code integer, a quantity integer, and an Item Content Structure that hosts the structures for different item types (Weapon Info, Armor Info, Consumable Info, Radar Info, Module Info, Engine Info Structures). When create an Item Content Structure Array and I resize the Item Content Structure Array alone it works fine. So it seems that having the added integers in the partent structure (Item Info) is apart of the problem? Where would I go to get a copy of the logs you are requesting.
New development! Having the array replicate causes the issue. If I do not have the Inventory Array replicate everything loads fine initially. My Inventory Widget shows the correct amount of Inventory Slots associated with the Array Index Length on begin play but when Items are added it does not show up client side. With the boolArray set to replicate I do not experience the same issue. Is there just to much data in the Array and is causing a loading issue when replicated?
If I preset the amount of Indexes in the Inventory Array it works perfectly as well replicated.
Also to add to this. Resizing to a lower Index amount while replicated does not produce the problem.
Then maybe it is a bug when resizing an replicated array of struct. I try to reproduce later. I guess it is a BP Struct or do you work with C++ Structs?
I’m only working with Blueprints in my game.