Add "set bots" command to make it possible to set SEND_AGENT_UPDATES on all bots whilst pCampbot is running

0.7.6-extended
Justin Clark-Casey (justincc) 2013-08-22 23:11:05 +01:00
parent beb9d966f9
commit 51c7fb1969
1 changed files with 27 additions and 0 deletions

View File

@ -202,6 +202,9 @@ namespace pCampBot
"bot", false, "stand", "stand", "Stand all bots.",
HandleStand);
m_console.Commands.AddCommand(
"bot", false, "set bots", "set bots <key> <value>", "Set a setting for all bots.", HandleSetBots);
m_console.Commands.AddCommand(
"bot", false, "show regions", "show regions", "Show regions known to bots", HandleShowRegions);
@ -519,6 +522,30 @@ namespace pCampBot
Environment.Exit(0);
}
private void HandleSetBots(string module, string[] cmd)
{
string key = cmd[2];
string rawValue = cmd[3];
if (key == "SEND_AGENT_UPDATES")
{
bool newSendAgentUpdatesSetting;
if (!ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, rawValue, out newSendAgentUpdatesSetting))
return;
MainConsole.Instance.OutputFormat(
"Setting SEND_AGENT_UPDATES to {0} for all bots", newSendAgentUpdatesSetting);
lock (m_bots)
m_bots.ForEach(b => b.Client.Settings.SEND_AGENT_UPDATES = newSendAgentUpdatesSetting);
}
else
{
MainConsole.Instance.Output("Error: Only setting currently available is SEND_AGENT_UPDATES");
}
}
private void HandleShowRegions(string module, string[] cmd)
{
string outputFormat = "{0,-30} {1, -20} {2, -5} {3, -5}";