Added destroy instance in DataController after death
This commit is contained in:
@@ -474,4 +474,12 @@ function DataController.GetInstance(username)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function DataController.DestroyInstance(username)
|
||||
if DataController.instances[username] ~= nil then
|
||||
DataController.instances[username] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return DataController
|
||||
@@ -36,16 +36,15 @@ function Main.InitializePlayer()
|
||||
CommonMethods.SafeStartEvent("OnTick", TryToInitialize)
|
||||
end
|
||||
|
||||
---Clean the TOC table for that SP player, to prevent from clogging it up
|
||||
---Clean the TOC table for that SP player, to prevent it from clogging ModData up
|
||||
---@param player IsoPlayer
|
||||
function Main.WipeData(player)
|
||||
TOC_DEBUG.print("Wiping data after death")
|
||||
local key = CommandsData.GetKey(player:getUsername())
|
||||
local username = player:getUsername()
|
||||
TOC_DEBUG.print("Wiping data after death: " .. username)
|
||||
local key = CommandsData.GetKey(username)
|
||||
|
||||
--ModData.remove(key)
|
||||
|
||||
|
||||
|
||||
if not isClient() then
|
||||
-- For SP, it's enough just removing the data this way
|
||||
ModData.remove(key)
|
||||
@@ -54,7 +53,14 @@ function Main.WipeData(player)
|
||||
-- at the next character by passing an empty mod data
|
||||
ModData.add(key, {})
|
||||
ModData.transmit(key)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Let's wipe the instance too just to be sure
|
||||
local DataController = require("TOC/Controllers/DataController")
|
||||
DataController.DestroyInstance(username)
|
||||
|
||||
end
|
||||
|
||||
--* Events *--
|
||||
|
||||
Reference in New Issue
Block a user