Jump to content

Recommended Posts

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

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)

 

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
×
  • Create New...