diff --git a/sources/Commands/Command.uc b/sources/Commands/Command.uc index 54fdb5f..d45f0d3 100644 --- a/sources/Commands/Command.uc +++ b/sources/Commands/Command.uc @@ -357,6 +357,10 @@ public final function bool Execute(CallData callData, EPlayer callerPlayer) ReportError(callData, callerPlayer); return false; } + callerPlayer.BorrowConsole() + .Write(P("Executing command `")) + .Write(commandData.name) + .Say(P("`")); Executed(callData, callerPlayer); if (commandData.requiresTarget) { diff --git a/sources/Commands/Commands.uc b/sources/Commands/Commands.uc index ba85ca0..37ecaeb 100644 --- a/sources/Commands/Commands.uc +++ b/sources/Commands/Commands.uc @@ -21,8 +21,9 @@ class Commands extends FeatureConfig perobjectconfig config(AcediaSystem); -var public config bool useChatInput; -var public config bool useMutateInput; +var public config bool useChatInput; +var public config bool useMutateInput; +var public config string chatCommandPrefix; protected function AssociativeArray ToData() { @@ -30,27 +31,38 @@ protected function AssociativeArray ToData() data = __().collections.EmptyAssociativeArray(); data.SetBool(P("useChatInput"), useChatInput, true); data.SetBool(P("useMutateInput"), useMutateInput, true); + data.SetItem( P("chatCommandPrefix"), + _.text.FromString(chatCommandPrefix), true); return data; } protected function FromData(AssociativeArray source) { - if (source != none) - { - useChatInput = source.GetBool(P("useChatInput")); - useMutateInput = source.GetBool(P("useMutateInput")); + local Text newChatPrefix; + if (source == none) { + return; } + useChatInput = source.GetBool(P("useChatInput")); + useMutateInput = source.GetBool(P("useMutateInput")); + newChatPrefix = source.GetText(P("chatCommandPrefix")); + chatCommandPrefix = "!"; + if (newChatPrefix != none) { + chatCommandPrefix = newChatPrefix.ToString(); + } + _.memory.Free(newChatPrefix); } protected function DefaultIt() { - useChatInput = true; - useMutateInput = true; + useChatInput = true; + useMutateInput = true; + chatCommandPrefix = "!"; } defaultproperties { configName = "AcediaSystem" - useChatInput = true - useMutateInput = true + useChatInput = true + useMutateInput = true + chatCommandPrefix = "!" } \ No newline at end of file diff --git a/sources/Commands/Commands_Feature.uc b/sources/Commands/Commands_Feature.uc index d1e7d6a..2b44b9a 100644 --- a/sources/Commands/Commands_Feature.uc +++ b/sources/Commands/Commands_Feature.uc @@ -29,11 +29,16 @@ var private array commandDelimiters; var private AssociativeArray registeredCommands; // Setting this to `true` enables players to input commands right in the chat -// by prepending them with "!" character. +// by prepending them with `chatCommandPrefix`. +// Default is `true`. var private /*config*/ bool useChatInput; // Setting this to `true` enables players to input commands with "mutate" // console command. +// Default is `true`. var private /*config*/ bool useMutateInput; +// Chat messages, prepended by this prefix will be treated as commands. +// Default is "!". Empty values are also treated as "!". +var private /*config*/ Text chatCommandPrefix; var LoggerAPI.Definition errCommandDuplicate; @@ -68,6 +73,8 @@ protected function OnDisabled() registeredCommands = none; } commandDelimiters.length = 0; + _.memory.Free(chatCommandPrefix); + chatCommandPrefix = none; } protected function SwapConfig(FeatureConfig config) @@ -77,6 +84,8 @@ protected function SwapConfig(FeatureConfig config) if (newConfig == none) { return; } + _.memory.Free(chatCommandPrefix); + chatCommandPrefix = _.text.FromString(newConfig.chatCommandPrefix); if (useChatInput != newConfig.useChatInput) { useChatInput = newConfig.useChatInput; @@ -245,9 +254,9 @@ private function bool HandleCommands( bool teamMessage) { local Parser parser; - // We are only interested in messages that start with "!" + // We are only interested in messages that start with `chatCommandPrefix` parser = _.text.Parse(message); - if (!parser.Match(P("!")).Ok()) + if (!parser.Match(chatCommandPrefix).Ok()) { parser.FreeSelf(); return true;