From db3b9c2fa11a5e7ba8294fc980753713e7894efd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 7 Sep 2007 02:20:08 +0000 Subject: [PATCH] added amb923 - CheckCommandAccess() changes --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401405 --- core/msvc8/sourcemod_mm.vcproj | 2 +- core/smn_console.cpp | 9 ++++++++- plugins/include/console.inc | 21 ++++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/msvc8/sourcemod_mm.vcproj b/core/msvc8/sourcemod_mm.vcproj index 396e3b41..03076cea 100644 --- a/core/msvc8/sourcemod_mm.vcproj +++ b/core/msvc8/sourcemod_mm.vcproj @@ -535,7 +535,7 @@ > LocalToString(params[2], &cmd); - return g_ConCmds.CheckCommandAccess(params[1], cmd, params[3]) ? 1 : 0; + /* Support the newer version which will auto-check for an existing command. */ + FlagBits bits = params[3]; + if (params[0] == 4 && params[4]) + { + g_ConCmds.LookForCommandAdminFlags(cmd, &bits); + } + + return g_ConCmds.CheckCommandAccess(params[1], cmd, bits) ? 1 : 0; } REGISTER_NATIVES(consoleNatives) diff --git a/plugins/include/console.inc b/plugins/include/console.inc index d2f65b8c..27e9db97 100644 --- a/plugins/include/console.inc +++ b/plugins/include/console.inc @@ -640,12 +640,23 @@ native bool:ReadCommandIterator(Handle:iter, descLen=0); /** - * Returns whether a client has access to a command. This takes into account - * the override system built into SourceMod. + * Returns whether a client has access to a given command string. The string + * can also be any override string, as overrides can be independent of + * commands. This important feature essentially allows you to create custom + * flags using the override system. * * @param client Client index. - * @param command Command name. - * @param flags Default command flags. + * @param command Command name. If the command is not found, the default + * flags are used. + * @param flags Flag string to use as a default, if the command or override + * is not found. + * @param override_only If true, SourceMod will not attempt to find a matching + * command, and it will only use the default flags specified. + * Otherwise, SourceMod will ignore the default flags if + * there is a matching admin command. * @return True if the client has access, false otherwise. */ -native bool:CheckCommandAccess(client, const String:command[], flags); +native bool:CheckCommandAccess(client, + const String:command[], + flags, + bool:override_only=false);