Sign in to follow this  
Maxsar

Character mod crashes server on load [code included] pls help!

Recommended Posts

Maxsar    1

So i added custom component to character and its crashing when:

  1. i enter cave
  2. 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

Share this post


Link to post
Share on other sites
Maxsar    1

Ok it doesnt save values after server restart. What ma i doing wrong this time? xD

 

edit.

fixed it.

Edited by Maxsar

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this