Spyler.X 625 Posted December 6, 2018 Hi I'm starting to work on a game, and I was wondering if there is a simple way to keep the player's inventory, to always have that information in our game. I see two ways of doing it but I do not know which works best. One is to generate an inventory for each one, and when the player disconnects, the inventory is saved until it is reconnected, obviously this is giving me problems because it involves a lot of complicated logic for me. But it is a way to eliminate the player from the game without losing inventory. The other way I can think is to keep players disconnected in a room, it's easier, but I'm not sure if it would affect performance. I also thought that maybe eliminating the player does not eliminate their inventory, but I've had problems with that in the past, so I'm not sure it's the best option. Share this post Link to post Share on other sites
Igor Q. 519 Posted December 6, 2018 The easiest way I can imagine doing this would be when a player triggers the action via dying, disconnecting, saving or etc. Create a man npc and attach it to label "player save". Then run a script that saves the inventory using an array and giving it to a new npc and giving it the same name as player. Once a player joins the game make the trigger search for each entity within the label "player save". If the string names match for both the npc and the player give NPC items to player and delete NPC. Share this post Link to post Share on other sites
Igor Q. 519 Posted December 6, 2018 (edited) Here ya go my dude. If you have questions, let me know. Edit: "Set Counter" is a Local Variable I added to the script. Edit 1: Set for "Spawn Point 1" -> REPEAT TIMES GET LENGTH Array GET LABELS Game Logic #4: Player Save Label Edited December 6, 2018 by Igor Quintero 1 Share this post Link to post Share on other sites
Spyler.X 625 Posted December 6, 2018 Thank you very much @Igor Quintero, I'm going to put on that, I can make my system follow that path, but I think I'll start again to not complicate Share this post Link to post Share on other sites
Igor Q. 519 Posted December 6, 2018 Just remember though, as of this moment all multiplayer games that you load and save will store player information and items into a temp save file. Which means you technically don't need this code since it already includes an "save and auto load" for all characters (UNLESS you start a new session of the game, which also makes the previous code obsolete) 1 Share this post Link to post Share on other sites
RedEagle_P1. 905 Posted December 6, 2018 Remember if what you doing is more than 1 chunk big, teleporting people outside visual range causes crashes 1 Share this post Link to post Share on other sites
Spyler.X 625 Posted December 6, 2018 thank you guys I'll keep all that in mind, I still have a lot to learn. Share this post Link to post Share on other sites
Hunter-Over-Fire 123 Posted March 26, 2020 420 posts. Share this post Link to post Share on other sites