MicheaBoab Posted May 23, 2024 Share Posted May 23, 2024 Hey guys, currently I added a variable numTotal in the Waxwell's prefab called _numTotal and each time he used the book this number will increase by one, but how can I store this number when the user is leaving the server? currently it will reset to default number after re-join the server Link to comment https://forums.kleientertainment.com/forums/topic/156296-need-help-to-store-the-data-when-exsit-the-server/ Share on other sites More sharing options...
LeafyFly Posted May 23, 2024 Share Posted May 23, 2024 Decorate Waxwell's OnSave and OnLoad. Or put numTotal in your component which has OnSave and OnLoad. Then add the component on Waxwell in AddPrefabPostInit. Link to comment https://forums.kleientertainment.com/forums/topic/156296-need-help-to-store-the-data-when-exsit-the-server/#findComment-1716501 Share on other sites More sharing options...
_zwb Posted May 24, 2024 Share Posted May 24, 2024 AddPrefabPostInit("waxwell", function(inst) local _OnSave = inst.OnSave local _OnLoad = inst.OnLoad inst.OnSave = function(inst, data) if _OnSave then _OnSave(inst, data) end data.numTotal = inst._numTotal end inst.OnLoad = function(inst, data) if _OnLoad then _OnLoad(inst, data) end if data and data.numTotal then inst._numTotal = data.numTotal end end end) Link to comment https://forums.kleientertainment.com/forums/topic/156296-need-help-to-store-the-data-when-exsit-the-server/#findComment-1716652 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