The whole point of this is that by having the flags only, I need to check if they are sufficient to access a command.
Here's a method of creating a temporary anonymous admin, setting their flags and then using it for
CheckAccess.
PHP Code:
stock bool CheckCommandAccessFlags(const char[] sCmd, const char[] sFlags){
AdminId hAdmin = CreateAdmin("");
int i = -1;
AdminFlag eFlag;
while(sFlags[++i] != '\0')
if(FindFlagByChar(sFlags[i], eFlag))
hAdmin.SetFlag(eFlag, true);
bool bResult = CheckAccess(hAdmin, sCmd, 0, false);
RemoveAdmin(hAdmin);
return bResult;
}
I've found that it works properly, and has the additional benefit of respecting the overrides.
Quote:
Originally Posted by eyal282
Iterator is best, use it.
|
I have over 400 sm commands, would iterating all of them be faster than creating a temp admin every time?