This commit is contained in:
ZioPao
2023-11-13 03:15:37 +01:00
parent 980545a07e
commit deb6dcc056
9 changed files with 31 additions and 136 deletions

View File

@@ -1,8 +1,4 @@
if isClient() then return end
if isClient() then return end -- The event makes this necessary to prevent clients from running this file
local ServerDataHandler = {}
ServerDataHandler.modData = {}
@@ -14,7 +10,9 @@ function ServerDataHandler.GetTable(key)
return ServerDataHandler.modData[key]
end
---Add table to the ModData and a local table
---@param key string
---@param table tocModData
function ServerDataHandler.AddTable(key, table)
ModData.add(key, table) -- Add it to the server mod data
ServerDataHandler.modData[key] = table

View File

@@ -1,42 +0,0 @@
local CommandsData = require("TOC/CommandsData")
local ServerSyncCommands = {}
local moduleName = CommandsData.modules.TOC_SYNC
------------------------------
-- TODO This is gonna be impossible to manage. We need Global Mod Data to keep track of this kind of stuff at this point
---A client has asked the server to ask another client to send its toc mod data
---@param surgeonPl IsoPlayer
---@param args askPlayerDataParams
function ServerSyncCommands.AskPlayerData(surgeonPl, args)
local patientPl = getSpecificPlayer(args.patientNum)
---@type sendPlayerDataParams
local params = {surgeonNum = surgeonPl:getOnlineID()}
sendServerCommand(patientPl, moduleName, CommandsData.client.Sync.SendPlayerData, params)
end
---Relay the toc mod data from a certain player to another one
---@param patientPl IsoPlayer
---@param args relayPlayerDataParams
function ServerSyncCommands.RelayPlayerData(patientPl, args)
local surgeonPl = getSpecificPlayer(args.surgeonNum)
local patientNum = patientPl:getOnlineID()
---@type receivePlayerDataParams
local params = {patientNum = patientNum, tocData = args.tocData}
sendServerCommand(surgeonPl, moduleName, CommandsData.client.Sync.ReceivePlayerData, params)
end
------------------------------
local function OnClientSyncCommand(module, command, playerObj, args)
if module == moduleName and ServerSyncCommands[command] then
ServerSyncCommands[command](playerObj, args)
end
end
Events.OnClientCommand.Add(OnClientSyncCommand)