[CommandHandler] Add /load command for loading scripts on the fly

This commit is contained in:
David Cernat
2019-03-08 04:26:18 +02:00
parent 06f0c5a3ad
commit dad68f5e1f
2 changed files with 23 additions and 0 deletions
+21
View File
@@ -822,6 +822,27 @@ function commandHandler.ProcessCommand(pid, cmd)
logicHandler.SendConfigCollisionOverrides(pid, true)
Players[pid]:Message(message .. " for " .. refId .. " in newly loaded cells\n")
elseif cmd[1] == "load" and admin then
local scriptName = cmd[2]
if scriptName == nil then
Players[pid]:Message("Use /load <scriptName>\n")
else
if package.loaded[scriptName] then
Players[pid]:Message(scriptName .. " was already loaded, so it is being reloaded.\n")
package.loaded[scriptName] = nil
end
local result = prequire(scriptName)
if result then
Players[pid]:Message(scriptName .. " was successfully loaded.\n")
else
Players[pid]:Message(scriptName .. " could not be found.\n")
end
end
elseif cmd[1] == "resetkills" and moderator then
-- Set all currently recorded kills to 0 for connected players