From e6bcab0960f675a733ceaf64919ac402c8c6ac79 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:09:12 +0200 Subject: [PATCH] chat_commands 1.4.3 Made it so that players can type commands and "me" (when targeting a player) any way they want. There doesn't need to be an exact match full lower case anymore for both of these --- chat_commands/chat_commands.gsc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/chat_commands/chat_commands.gsc b/chat_commands/chat_commands.gsc index f39c556..9aa5b0b 100644 --- a/chat_commands/chat_commands.gsc +++ b/chat_commands/chat_commands.gsc @@ -62,6 +62,7 @@ InitChatCommandsDvars() CreateCommand(serverPorts, commandName, commandType, commandValue, commandMinimumPermission, commandHelp, commandAliases) { currentPort = GetDvar("net_port"); + commandName = ToLower(commandName); // always create commands in lower case to avoid any potential casing issue foreach (serverPort in serverPorts) { @@ -168,7 +169,7 @@ ChatListener() } commandArray = StrTok(message, " "); // Separate the command by space character. Example: ["!map", "mp_dome"] - command = commandArray[0]; // The command as text. Example: !map + command = ToLower(commandArray[0]); // The command as text in lower text to support any casing. Example: !map args = []; // The arguments passed to the command. Example: ["mp_dome"] arg = ""; @@ -251,7 +252,7 @@ ChatListener() } else { - originalCommandName = GetCommandNameFromAlias(args[0]); + originalCommandName = ToLower(GetCommandNameFromAlias(args[0])); if (args[0] == "commands" || args[0] == "help" || args[0] == "aliases" || args[0] == "alias") { @@ -316,7 +317,7 @@ ChatListener() } else { - originalCommandName = GetCommandNameFromAlias(args[0]); + originalCommandName = ToLower(GetCommandNameFromAlias(args[0])); if (args[0] == "commands" || args[0] == "help" || args[0] == "aliases" || args[0] == "alias") { @@ -332,7 +333,6 @@ ChatListener() if (IsDefined(commandAliases)) { - if (!PermissionIsEnabled() || PlayerHasSufficientPermissions(player, level.commands[GetDvar("net_port")][originalCommandName]["permission"])) { commandAliases = AddElementToArray(commandAliases, originalCommandName); @@ -363,7 +363,7 @@ ChatListener() } else // try to find the command by one of its aliases { - originalCommandName = GetCommandNameFromAlias(inputCommandName); + originalCommandName = ToLower(GetCommandNameFromAlias(inputCommandName)); if (inputCommandName == originalCommandName) // the command wasn't found while searching by its name and all the commands aliases { @@ -492,7 +492,7 @@ CamoDoesNotExistError(camoName) FindPlayerByName(name) { - if (name == "me") + if (ToLower(name) == "me") { return self; } @@ -632,6 +632,8 @@ If is not a valid alias then it just returns itself meaning it did */ GetCommandNameFromAlias(aliasToFind) { + aliasToFind = ToLower(aliasToFind); + foreach (commandName in GetArrayKeys(level.commands[GetDvar("net_port")])) { if (IsDefined(level.commands[GetDvar("net_port")][commandName]["aliases"])) @@ -670,7 +672,7 @@ IsBot() TargetIsMyself(targetName) { - return targetName == "me" || ToLower(targetName) == ToLower(self.name); + return ToLower(targetName) == "me" || ToLower(targetName) == ToLower(self.name); } GetWeaponNameWithoutCamo(weaponName)