Added destroy instance in DataController after death

This commit is contained in:
ZioPao
2024-05-05 21:07:33 +02:00
parent 9b1876b235
commit a7a064119d
2 changed files with 19 additions and 5 deletions

View File

@@ -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 *--