added amb923 - CheckCommandAccess() changes

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401405
This commit is contained in:
David Anderson 2007-09-07 02:20:08 +00:00
parent 08403e2b4a
commit db3b9c2fa1
3 changed files with 25 additions and 7 deletions

View File

@ -535,7 +535,7 @@
> >
</File> </File>
<File <File
RelativePath="..\sm_trie_tpl.h" RelativePath="..\..\public\sm_trie_tpl.h"
> >
</File> </File>
<File <File

View File

@ -977,7 +977,14 @@ static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params)
char *cmd; char *cmd;
pContext->LocalToString(params[2], &cmd); pContext->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) REGISTER_NATIVES(consoleNatives)

View File

@ -640,12 +640,23 @@ native bool:ReadCommandIterator(Handle:iter,
descLen=0); descLen=0);
/** /**
* Returns whether a client has access to a command. This takes into account * Returns whether a client has access to a given command string. The string
* the override system built into SourceMod. * 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 client Client index.
* @param command Command name. * @param command Command name. If the command is not found, the default
* @param flags Default command flags. * 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. * @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);