mirror of
https://github.com/Resxt/Plutonium-IW5-Scripts.git
synced 2025-04-19 12:42:54 +00:00
chat_commands 1.4.1
Push changes that should have been pushed with 1.4.0 Fix permission issues with aliases causing the script to return that a command doesn't exist when you don't have access to the alias instead of saying you don't have the permission as expected [Refactor] Change ExecuteCommand and TryExecuteCommand function names to reflect changes made in the T6 script that fixed an issue. The change here is only made to keep a logic between the scripts but that bug didn't exist in the IW5 version due to how IW5 works
This commit is contained in:
parent
b8b1e7c17e
commit
48bf8b8a0b
@ -112,7 +112,7 @@ CreateCommand(serverPorts, commandName, commandType, commandValue, commandMinimu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecuteCommand(command, args, player)
|
ExecuteChatCommand(command, args, player)
|
||||||
{
|
{
|
||||||
if (command["type"] == "text")
|
if (command["type"] == "text")
|
||||||
{
|
{
|
||||||
@ -129,11 +129,11 @@ ExecuteCommand(command, args, player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TryExecuteCommand(commandValue, commandName, args, player)
|
TryExecuteChatCommand(commandValue, commandName, args, player)
|
||||||
{
|
{
|
||||||
if (!PermissionIsEnabled() || PlayerHasSufficientPermissions(player, commandValue["permission"]))
|
if (!PermissionIsEnabled() || PlayerHasSufficientPermissions(player, commandValue["permission"]))
|
||||||
{
|
{
|
||||||
ExecuteCommand(commandValue, args, player);
|
ExecuteChatCommand(commandValue, args, player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -251,14 +251,36 @@ ChatListener()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
originalCommandName = GetCommandNameFromAlias(args[0]);
|
||||||
|
|
||||||
if (args[0] == "commands" || args[0] == "help" || args[0] == "aliases" || args[0] == "alias")
|
if (args[0] == "commands" || args[0] == "help" || args[0] == "aliases" || args[0] == "alias")
|
||||||
{
|
{
|
||||||
player thread TellPlayer(CommandHelpDoesNotExistError(args[0]), 1);
|
player thread TellPlayer(CommandHelpDoesNotExistError(args[0]), 1);
|
||||||
}
|
}
|
||||||
else
|
else if (args[0] == originalCommandName) // the command wasn't found while searching by its name and all the commands aliases
|
||||||
{
|
{
|
||||||
player thread TellPlayer(CommandDoesNotExistError(args[0]), 1);
|
player thread TellPlayer(CommandDoesNotExistError(args[0]), 1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commandHelp = level.commands[GetDvar("net_port")][originalCommandName]["help"];
|
||||||
|
|
||||||
|
if (IsDefined(commandHelp))
|
||||||
|
{
|
||||||
|
if (!PermissionIsEnabled() || PlayerHasSufficientPermissions(player, level.commands[GetDvar("net_port")][originalCommandName]["permission"]))
|
||||||
|
{
|
||||||
|
player thread TellPlayer(commandHelp, 1.5);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player thread TellPlayer(InsufficientPermissionError(player GetPlayerPermissionLevel(), args[0], level.commands[GetDvar("net_port")][originalCommandName]["permission"]), 1.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player thread TellPlayer(CommandHelpDoesNotExistError(args[0]), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,12 +331,20 @@ ChatListener()
|
|||||||
commandAliases = level.commands[GetDvar("net_port")][originalCommandName]["aliases"];
|
commandAliases = level.commands[GetDvar("net_port")][originalCommandName]["aliases"];
|
||||||
|
|
||||||
if (IsDefined(commandAliases))
|
if (IsDefined(commandAliases))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!PermissionIsEnabled() || PlayerHasSufficientPermissions(player, level.commands[GetDvar("net_port")][originalCommandName]["permission"]))
|
||||||
{
|
{
|
||||||
commandAliases = AddElementToArray(commandAliases, originalCommandName);
|
commandAliases = AddElementToArray(commandAliases, originalCommandName);
|
||||||
|
|
||||||
player thread TellPlayer(commandAliases, 1.5);
|
player thread TellPlayer(commandAliases, 1.5);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
player thread TellPlayer(InsufficientPermissionError(player GetPlayerPermissionLevel(), args[0], level.commands[GetDvar("net_port")][originalCommandName]["permission"]), 1.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
player thread TellPlayer(CommandAliasesDoesNotExistError(args[0]), 1);
|
player thread TellPlayer(CommandAliasesDoesNotExistError(args[0]), 1);
|
||||||
}
|
}
|
||||||
@ -329,7 +359,7 @@ ChatListener()
|
|||||||
|
|
||||||
if (IsDefined(commandValue)) // try to find the command by its original name
|
if (IsDefined(commandValue)) // try to find the command by its original name
|
||||||
{
|
{
|
||||||
TryExecuteCommand(commandValue, inputCommandName, args, player);
|
TryExecuteChatCommand(commandValue, inputCommandName, args, player);
|
||||||
}
|
}
|
||||||
else // try to find the command by one of its aliases
|
else // try to find the command by one of its aliases
|
||||||
{
|
{
|
||||||
@ -341,7 +371,7 @@ ChatListener()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TryExecuteCommand(level.commands[GetDvar("net_port")][originalCommandName], inputCommandName, args, player);
|
TryExecuteChatCommand(level.commands[GetDvar("net_port")][originalCommandName], inputCommandName, args, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user