Fixing prosthesis equipping and unequipping

This commit is contained in:
ZioPao
2023-11-16 19:45:11 +01:00
parent 43cf52cd02
commit fe6d88fa43
4 changed files with 76 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
local PlayerHandler = require("TOC/Handlers/PlayerHandler")
local CommonMethods = require("TOC/CommonMethods")
local CommandsData = require("TOC/CommandsData")
------------------
@@ -51,6 +52,9 @@ end
function Main.Initialize()
-- TODO In SP we should clean Global Mod Data when a player dies!
---Looop until we've successfully initialized the mod
local function TryToInitialize()
local pl = getPlayer()
@@ -66,7 +70,18 @@ function Main.Initialize()
CommonMethods.SafeStartEvent("OnTick", TryToInitialize)
end
---Clean the TOC table for that SP player, to prevent from clogging it up
---@param player IsoPlayer
function Main.WipeSinglePlayerData(player)
local key = CommandsData.GetKey(player:getUsername())
ModData.remove(key)
ModData.transmit(key)
end
--* Events *--
Events.OnGameBoot.Add(Main.Start)
Events.OnGameBoot.Add(Main.Start)
if not isClient() and not isServer() then
Events.OnPlayerDeath.Add(Main.WipeSinglePlayerData)
end