chat_commands 1.3.3

Only create variables for the port currently in-use
For example: there's no need to create level.chat_commands["27017"] if the currently used port is 27016. This simply adds a bunch of variables and child variables for no reason, this was a flawed implementation that create an array per port on every server. Now it will only create an array for its own port as expected

Removed 27018 from the default ports
This is to make the default experience more generic across other chat_commands projects. One port for default private games and another port the expected/most used port for dedicated servers
This commit is contained in:
Resxt 2023-06-15 14:04:57 +02:00
parent 375dceea87
commit 4b25be67f8

View File

@ -23,7 +23,7 @@ InitChatCommands()
InitChatCommandsDvars();
level.chat_commands = []; // don't touch
level.chat_commands["ports"] = ["27016", "27017", "27018"]; // an array of the ports of all your servers you want to have the script running on. This is useful to easily pass this array as first arg of CreateCommand to have the command on all your servers
level.chat_commands["ports"] = ["27016", "27017"]; // an array of the ports of all your servers you want to have the script running on. This is useful to easily pass this array as first arg of CreateCommand to have the command on all your servers
level.chat_commands["no_commands_message"] = ["^1No commands found", "You either ^1didn't add any chat_command file ^7to add a new command ^1or ^7there are ^1no command configured on this port", "chat_commands.gsc is ^1just the base system. ^7It doesn't provide any command on its own", "Also ^1make sure the ports are configured properly ^7in the CreateCommand function of your command file(s)"]; // the lines to print in the chat when the server doesn't have any command added
level.chat_commands["no_commands_wait"] = 6; // time to wait between each line in <level.chat_commands["no_commands_message"]> when printing that specific message in the chat
@ -61,7 +61,11 @@ InitChatCommandsDvars()
*/
CreateCommand(serverPorts, commandName, commandType, commandValue, commandMinimumPermission, commandHelp)
{
currentPort = GetDvar("net_port");
foreach (serverPort in serverPorts)
{
if (serverPort == currentPort)
{
level.commands[serverPort][commandName]["type"] = commandType;
@ -100,6 +104,7 @@ CreateCommand(serverPorts, commandName, commandType, commandValue, commandMinimu
level.commands[serverPort][commandName]["permission"] = GetDvarInt("cc_permission_default");
}
}
}
}