Maxsar Posted August 15, 2021 Share Posted August 15, 2021 So i added custom component to character and its crashing when: i enter cave i load existing world - creating new world is fine but when i disconnect and resume it teleports my character to some random spot and after few seconds crash server. here is code for component: --blood.lua local Blood = Class(function(self, inst) self.inst = inst self.max = 100 self.current = 0 end) function Blood:OnSave() return {currentblood = self.current} end function Blood:OnLoad(data) if data.currentblood then self.current = data.currentblood self:DoDelta(0, true) end end --Ustawia aktualna wartosc bloodpoints function Blood:SetCurrent(amount) self.current = amount end function Blood:GetCurrent() return self.current end return Blood and i add component to character this way inst:AddComponent("blood") its probably something with saving or loading, maybe? idk Link to comment Share on other sites More sharing options...
ZeroRyuk Posted August 18, 2021 Share Posted August 18, 2021 You're calling DoDelta in your OnLoad, but you don't have a function for it. Link to comment Share on other sites More sharing options...
Maxsar Posted August 18, 2021 Author Share Posted August 18, 2021 OMFG IM DUMB THANK YOU!!!!!! I WAS FIGTHING THIS FOR A WEEK NOW Q.Q THANK YOU SO MUCH 1 Link to comment Share on other sites More sharing options...
ZeroRyuk Posted August 18, 2021 Share Posted August 18, 2021 You're welcome lol 1 Link to comment Share on other sites More sharing options...
Maxsar Posted August 18, 2021 Author Share Posted August 18, 2021 (edited) Ok it doesnt save values after server restart. What ma i doing wrong this time? xD edit. fixed it. Edited August 18, 2021 by Maxsar Link to comment 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