Too much stuff to fix.
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
if isClient() then return end -- The event makes this necessary to prevent clients from running this file
|
||||
local StaticData = require("TOC/StaticData")
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local ServerDataHandler = {}
|
||||
ServerDataHandler.modData = {}
|
||||
|
||||
@@ -21,10 +26,36 @@ function ServerDataHandler.AddTable(key, table)
|
||||
if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end
|
||||
|
||||
TOC_DEBUG.print("Received TOC ModData: " .. tostring(key))
|
||||
TOC_DEBUG.printTable(table)
|
||||
--TOC_DEBUG.printTable(table)
|
||||
|
||||
-- Set that the data has been modified and it's updated on the server
|
||||
table.isUpdateFromServer = true
|
||||
|
||||
ModData.add(key, table) -- Add it to the server mod data
|
||||
ServerDataHandler.modData[key] = table
|
||||
|
||||
|
||||
-- Since this could be triggered by a different client than the one referenced in the key, we're gonna
|
||||
-- apply the changes back to the key client again to be sure that everything is in sync
|
||||
local username = CommandsData.GetUsername(key)
|
||||
TOC_DEBUG.print("Reapplying to " .. username)
|
||||
|
||||
-- Since getPlayerFromUsername doesn't work in mp, we're gonna do this workaround. ew
|
||||
local onlinePlayers = getOnlinePlayers()
|
||||
local selectedPlayer
|
||||
for i=0, onlinePlayers:size() - 1 do
|
||||
|
||||
---@type IsoPlayer
|
||||
local player = onlinePlayers:get(i)
|
||||
if player:getUsername() == username then
|
||||
selectedPlayer = player
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
TOC_DEBUG.print("Player username from IsoPlayer: " .. selectedPlayer:getUsername())
|
||||
sendServerCommand(selectedPlayer, CommandsData.modules.TOC_RELAY, CommandsData.client.Relay.ReceiveApplyFromServer, {})
|
||||
|
||||
end
|
||||
|
||||
Events.OnReceiveGlobalModData.Add(ServerDataHandler.AddTable)
|
||||
|
||||
@@ -28,7 +28,6 @@ function ServerRelayCommands.RelayExecuteAmputationAction(surgeonPl, args)
|
||||
sendServerCommand(patientPl, CommandsData.modules.TOC_RELAY, CommandsData.client.Relay.ReceiveExecuteAmputationAction, params)
|
||||
end
|
||||
|
||||
|
||||
--* ADMIN ONLY *--
|
||||
---Relay a local init from another client
|
||||
---@param adminObj IsoPlayer
|
||||
|
||||
Reference in New Issue
Block a user