Potential solution for #46: Merge pull request #47 from Qowyn/lua

This commit is contained in:
Evil Factory
2022-03-08 14:26:03 -03:00
committed by GitHub
2 changed files with 16 additions and 2 deletions

View File

@@ -489,8 +489,7 @@ namespace Barotrauma.Networking
DebugConsole.Command command = DebugConsole.FindCommand(commandName);
if (command == null)
{
DebugConsole.ThrowError("Error in " + ClientPermissionsFile + " - \"" + commandName + "\" is not a valid console command.");
continue;
command = new DebugConsole.Command(commandName, "", (_) => {}, null, true);
}
permittedCommands.Add(command);

View File

@@ -507,6 +507,21 @@ namespace Barotrauma
luaAddedCommand.Add(cmd);
DebugConsole.Commands.Add(cmd);
#if SERVER
foreach (var client in GameMain.Server.ConnectedClients) {
var index = client.PermittedConsoleCommands.FindIndex((pc) => pc.names[0] == cmd.names[0]);
if (index > -1) {
client.PermittedConsoleCommands[index] = cmd;
}
}
foreach (var permissions in GameMain.Server.ServerSettings.ClientPermissions) {
var index = permissions.PermittedCommands.FindIndex((pc) => pc.names[0] == cmd.names[0]);
if (index > -1) {
permissions.PermittedCommands[index] = cmd;
}
}
#endif
}
public List<DebugConsole.Command> Commands => DebugConsole.Commands;