mouse Posted July 2, 2015 Share Posted July 2, 2015 (edited) I'm trying to save one variable and the usual DS inst.OnSave/inst.OnLoad method isn't working for disconnects/reconnects. Is there some special function or method I need to know about saving data in DST? Edited July 2, 2015 by mouse Link to comment https://forums.kleientertainment.com/forums/topic/55810-saving-player-data-via-onsaveonload/ Share on other sites More sharing options...
Seiai Posted July 2, 2015 Share Posted July 2, 2015 @mouse, they work, but some things like follower will already have been removed at that point. u can use OnDespawn then. just be aware that OnDespawn doesnt have access to the savedata yet, so u will have to save whatever u need into a variable on your character, and then save it via the savefunction. my mod kerrigan makes use of that to save her followers. Link to comment https://forums.kleientertainment.com/forums/topic/55810-saving-player-data-via-onsaveonload/#findComment-651408 Share on other sites More sharing options...
mouse Posted July 2, 2015 Author Share Posted July 2, 2015 @mouse,they work, but some things like follower will already have been removed at that point. u can use OnDespawn then. just be aware that OnDespawn doesnt have access to the savedata yet, so u will have to save whatever u need into a variable on your character, and then save it via the savefunction. my mod kerrigan makes use of that to save her followers.And they work within AddPlayerPostInit?Like:AddPlayerPostInit(function(inst) inst.OnSave=somefn1 inst.OnLoad=somefn2end) Link to comment https://forums.kleientertainment.com/forums/topic/55810-saving-player-data-via-onsaveonload/#findComment-651412 Share on other sites More sharing options...
mouse Posted July 2, 2015 Author Share Posted July 2, 2015 Nevermind, I found a solution. I made the player perform a dotaskintime function for one second after joining the server while all of the data finishes arm wrestling with each other. I noticed something though. The inst.OnSave function runs when the player joins the server. Any idea if that's a bug, temporary(until OnDespawn is finished), or permanent? Anyways, thank you very much for your help. Link to comment https://forums.kleientertainment.com/forums/topic/55810-saving-player-data-via-onsaveonload/#findComment-651423 Share on other sites More sharing options...
Amalleus Posted July 2, 2015 Share Posted July 2, 2015 I used load and save functions for my character and they work fine. Save - only when you come out of server. Load - only when you join the server. So, save doesn't work on joining for me, probably you have bug Link to comment https://forums.kleientertainment.com/forums/topic/55810-saving-player-data-via-onsaveonload/#findComment-651439 Share on other sites More sharing options...
Seiai Posted July 4, 2015 Share Posted July 4, 2015 (edited) And they work within AddPlayerPostInit?Like:AddPlayerPostInit(function(inst) inst.OnSave=somefn1 inst.OnLoad=somefn2end)if u do this, make sure to save the previous function of thoses players, and call them within your savefunction, or u will just overwrite existing savefunction, and for instance delete wendies sister like that^^ The inst.OnSave function runs when the player joins the server.i hope u are aware that the function gets called everytime the server saves, for instance each new day. so the function u make, has to work correctly even while gameplay, so it should'nt matter anyway, when it's being called when u join the game. so i would rather call it a feature than a bug^^ Edited July 4, 2015 by Seiai Link to comment https://forums.kleientertainment.com/forums/topic/55810-saving-player-data-via-onsaveonload/#findComment-651888 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now