From bf20aec94f91ce50167bf16af873cec54d926510 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Fri, 23 Aug 2024 02:53:04 +0200 Subject: [PATCH] Fixed admin commands in sp --- media/lua/client/TOC/Admin.lua | 21 ++++++++++++++++---- media/lua/client/TOC/ClientRelayCommands.lua | 3 +++ media/lua/client/TOC/CommonMethods.lua | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/media/lua/client/TOC/Admin.lua b/media/lua/client/TOC/Admin.lua index 2fd6797..1e0390d 100644 --- a/media/lua/client/TOC/Admin.lua +++ b/media/lua/client/TOC/Admin.lua @@ -1,4 +1,5 @@ local CommandsData = require("TOC/CommandsData") +local ClientRelayCommands = require("TOC/ClientRelayCommands") local StaticData = require("TOC/StaticData") local DataController = require("TOC/Controllers/DataController") ------------------- @@ -7,7 +8,8 @@ local DataController = require("TOC/Controllers/DataController") ---@param context ISContextMenu ---@param worldobjects table local function AddAdminTocOptions(playerNum, context, worldobjects) - if not isAdmin() then return end + + if (isClient() and not isDebugEnabled()) or isAdmin() then return end local players = {} for _, v in ipairs(worldobjects) do @@ -40,8 +42,13 @@ local function AddAdminTocOptions(playerNum, context, worldobjects) context:addSubMenu(option, subMenu) subMenu:addOption(getText("ContextMenu_Admin_ResetTOC"), nil, function() - sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization, - { patientNum = clickedPlayerNum }) + if isClient() then + sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization, + { patientNum = clickedPlayerNum }) + else + -- TODO ugly + ClientRelayCommands.ReceiveExecuteInitialization() + end end) -- Force amputation @@ -54,8 +61,14 @@ local function AddAdminTocOptions(playerNum, context, worldobjects) local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName) forceAmpSubMenu:addOption(limbTranslatedName, nil, function() - sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayForcedAmputation, + if isClient() then + sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayForcedAmputation, { patientNum = clickedPlayerNum, limbName = limbName }) + else + ClientRelayCommands.ReceiveExecuteAmputationAction({surgeonNum=clickedPlayerNum, limbName=limbName, damagePlayer=false}) + -- todo ugly + end + end) end end diff --git a/media/lua/client/TOC/ClientRelayCommands.lua b/media/lua/client/TOC/ClientRelayCommands.lua index ae5b3b9..354a690 100644 --- a/media/lua/client/TOC/ClientRelayCommands.lua +++ b/media/lua/client/TOC/ClientRelayCommands.lua @@ -72,3 +72,6 @@ local function OnServerRelayCommand(module, command, args) end Events.OnServerCommand.Add(OnServerRelayCommand) + +-- TODO temporary +return ClientRelayCommands \ No newline at end of file diff --git a/media/lua/client/TOC/CommonMethods.lua b/media/lua/client/TOC/CommonMethods.lua index 5c96a80..2a6f15e 100644 --- a/media/lua/client/TOC/CommonMethods.lua +++ b/media/lua/client/TOC/CommonMethods.lua @@ -26,7 +26,7 @@ end ---Returns full name for the side, to be used with BodyLocations ---@param side string ----@return string +---@return string? function CommonMethods.GetSideFull(side) if side == 'R' then return "Right"