diff --git a/42/media/lua/client/TOC/ClientRelayCommands.lua b/42/media/lua/client/TOC/ClientRelayCommands.lua index 354a690..52d3050 100644 --- a/42/media/lua/client/TOC/ClientRelayCommands.lua +++ b/42/media/lua/client/TOC/ClientRelayCommands.lua @@ -46,6 +46,17 @@ function ClientRelayCommands.ReceiveApplyFromServer() end +--* RELOAD MODEL *-- +function ClientRelayCommands.ReceiveReloadModel(args) + local texId = args.texId + local itemName = args.itemName + TOC_DEBUG.print("Resetting visuals locally for item " .. itemName .. " with texId " .. tostring(texId)) + + local clothingItem = getPlayer():getInventory():FindAndReturn(itemName) + getPlayer():setWornItem(clothingItem:getBodyLocation(), clothingItem) + +end + --* TRIGGERED BY ADMINS *-- function ClientRelayCommands.ReceiveExecuteInitialization() diff --git a/42/media/lua/client/TOC/Handlers/AmputationHandler.lua b/42/media/lua/client/TOC/Handlers/AmputationHandler.lua index 67f3e41..8aa66c7 100644 --- a/42/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/42/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -184,8 +184,6 @@ function AmputationHandler:execute(damagePlayer) sendClientCommand(CommandsData.modules.TOC_ITEMS, "SpawnAmputationItem", {playerNum = self.patientPl:getOnlineID(), limbName = self.limbName}) - --ItemsController.Player.DeleteOldAmputationItem(self.patientPl, self.limbName) - --ItemsController.Player.SpawnAmputationItem(self.patientPl, self.limbName) -- Add it to the list of cut limbs on this local client local username = self.patientPl:getUsername() diff --git a/42/media/lua/server/TOC/Controllers/ItemsController.lua b/42/media/lua/server/TOC/Controllers/ItemsController.lua index 7b81bf7..1692390 100644 --- a/42/media/lua/server/TOC/Controllers/ItemsController.lua +++ b/42/media/lua/server/TOC/Controllers/ItemsController.lua @@ -2,6 +2,8 @@ local StaticData = require("TOC/StaticData") local CommonMethods = require("TOC/CommonMethods") +local CommandsData = require("TOC/CommandsData") + --------------------------- --- Submodule to handle spawning the correct items after certain actions (ie: cutting a hand). LOCAL ONLY! @@ -97,11 +99,7 @@ function ItemsController.Player.DeleteAllOldAmputationItems(playerObj) ---@cast clothItem InventoryItem ItemsController.Player.RemoveClothingItem(playerObj, clothItem) end - -- Reset model just in case - playerObj:resetModel() - -- group:setMultiItem("TOC_Arm", true) - -- group:setMultiItem("TOC_ArmProst", true) end ---Spawns and equips the correct amputation item to the player. @@ -109,14 +107,15 @@ end ---@param limbName string function ItemsController.Player.SpawnAmputationItem(playerObj, limbName) TOC_DEBUG.print("clothing name " .. StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) - local clothingItem = playerObj:getInventory():AddItem(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) + local itemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName + local clothingItem = playerObj:getInventory():AddItem(itemName) local texId = ItemsController.Player.GetAmputationTexturesIndex(playerObj, false) ---@cast clothingItem InventoryItem clothingItem:getVisual():setTextureChoice(texId) -- it counts from 0, so we have to subtract 1 - playerObj:setWornItem(clothingItem:getBodyLocation(), clothingItem) sendAddItemToContainer(playerObj:getInventory(), clothingItem) + sendServerCommand(CommandsData.modules.TOC_RELAY, CommandsData.client.Relay.ReceiveWearAmputation, {itemName = itemName, texId = texId}) end ---Search through worn items and modifies a specific amputation item diff --git a/42/media/lua/shared/TOC/CommandsData.lua b/42/media/lua/shared/TOC/CommandsData.lua index d111633..ac5612d 100644 --- a/42/media/lua/shared/TOC/CommandsData.lua +++ b/42/media/lua/shared/TOC/CommandsData.lua @@ -16,6 +16,7 @@ CommandsData.client = { --* APPLY *-- ReceiveApplyFromServer = "ReceiveApplyFromServer", + ReceiveWearAmputation = "ReceiveWearAmputation", --* ADMIN ONLY --* ReceiveExecuteInitialization = "ReceiveExecuteInitialization",