79 lines
2.1 KiB
Lua
79 lines
2.1 KiB
Lua
--- A rly big thx to Fenris_Wolf and Chuck to help me with that. Love you guy
|
|
--if isClient() then return end
|
|
|
|
---Server side
|
|
local Commands = {}
|
|
|
|
|
|
--TODO how does this work
|
|
Commands["SendServer"] = function(player, arg)
|
|
local otherPlayer = getPlayerByOnlineID(arg["To"])
|
|
print("The Only Cure Command: ", arg['command'])
|
|
sendServerCommand(otherPlayer, "TOC", arg["command"], arg)
|
|
end
|
|
|
|
|
|
-- To make the UI Work
|
|
Commands["GetPlayerData"] = function(_, arg)
|
|
local surgeon_id = arg[1]
|
|
local patient_id = arg[2]
|
|
local patient = getPlayerByOnlineID(arg[2])
|
|
sendServerCommand(patient, "TOC", "GivePlayerData", { surgeon_id, patient_id })
|
|
end
|
|
|
|
Commands["SendPlayerData"] = function(_, arg)
|
|
local surgeon = getPlayerByOnlineID(arg[1])
|
|
local surgeon_id = arg[1]
|
|
local toc_data = arg[2]
|
|
sendServerCommand(surgeon, "TOC", "SendTocData", { surgeon_id, toc_data })
|
|
end
|
|
|
|
|
|
|
|
-- CHEATING STUFF
|
|
Commands["AskToResetEverything"] = function(_, arg)
|
|
local clicked_player = getPlayerByOnlineID(arg[1])
|
|
local clicked_player_id = arg[1]
|
|
|
|
|
|
sendServerCommand(clicked_player, "TOC", "AcceptResetEverything", { clicked_player_id })
|
|
|
|
end
|
|
|
|
-- local function OnTocClientCommand(module, command, player, args)
|
|
-- if module == 'TOC' then
|
|
-- print("OnTocClientCommand " .. command)
|
|
-- if Commands[command] then
|
|
-- args = args or {}
|
|
-- Commands[command](_, args)
|
|
-- end
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--Events.OnClientCommand.Add(OnTocClientCommand)
|
|
|
|
-------------------------------- TEST ------------------------
|
|
|
|
TOC_Commands = {}
|
|
|
|
function TOC_OnInitGlobalModData()
|
|
ModData.getOrCreate("TOC_PLAYER_DATA")
|
|
end
|
|
|
|
Events.OnInitGlobalModData.Add(TOC_OnInitGlobalModData)
|
|
|
|
TOC_Commands.OnClientCommand = function(module, command, playerObj, args)
|
|
if module == 'TOC' and TOC_Commands[command] then
|
|
TOC_Commands[command](playerObj, args)
|
|
end
|
|
end
|
|
|
|
|
|
Events.OnClientCommand.Add(TOC_Commands.OnClientCommand)
|
|
|
|
|
|
TOC_Commands.ChangePlayerState = function(playerObj, args)
|
|
ModData.get("TOC_PLAYER_DATA")[playerObj:getUsername()] = args
|
|
ModData.transmit("TOC_PLAYER_DATA")
|
|
end |