When u enter the level a loading screen appears, 1 second is delayed just to make sure every player is in, if player is server then it will load and with a delay of 0,2 seconds to make sure its loaded, it will save again. then the last 0,3 seconds are just for aesthetics.
Ik, just added it to make it easier to “access” but it does the same as the ue5 default booleans
those delays don’t ensure anything, a player could load, or not and you have no way of knowing.
your multiplayer bool isnt replicated so clients could go the false path and load their own game, but as i said i see no reason for this bool, only the server should load
the multiplayer bool is from the game instance, so it doesnt need to be replicated.
equally the things you mentioned are not part of the problem as they were tested using prints and i can confirm that players load correctly before executing the save and load functions.
also testing a little bit more i can confirm that the clients’ items doesnt get saved.
the client isnt saving or loading either, is the server who has the savegame. Also what i need to ref is the player character not the controller, which i tried to do using “Get Owning Player Pawn” (5th image)
Both numbers of items should be 3 but for some reason the client doesnt save their items.
Still seeing the problem in-game i dont know where the problem is in-code (i think its getting the player pawn in widget) but still could you indicate me what to do? thx in advance!
looking at that your using a widget but widgets only exists on clients. my guess is when you setitems your clearing the array the client returns null and doesnt repopulate it.
Well, still i dont have any other component where i can call the set items array event as its supposed to get called when an item is added or dropped. So what can I do?
adding and removing all needs to be server side. you replicate the array to the clients and the clients can have widgets display the data but not alter it
Item array is in the player character. This should work like this: when the client drops or picks an item an event is called. This event clears the array, gets all items and adds them to the array. Then the server when saving event is called gets the array from the client and adds it to another array in the SaveGame.
why clear it at all? why not just add/remove the item?
either way it has to be done server side.
currently if you clear it server side the widgets will fail (or be a server copy) and if you do it client side the widgets may work but the items will be overwritten by server since it has authority and its replicated
hey! srry for answering late, i was full of exams.
anyway. I followed your steps and remade the item adding and removing system.
so what happens now is that when i pick up an item, it adds to the items array but it doesnt display on the widget (image below to prove its in the array)
where are you telling the widget to update? you’re setting the item but you’ll need a function to update the icon etc
also OnRep isnt always called on server so what id do is make a function UpdateInventory and call it when the server changes and in the OnRep for clients
Making the UpdateInventory function works the item display issue. Now the issue is that when the items are saved happens something… weird
(The first player had 2 items and the second 3)