Raised This Month: $275 Target: $400
 68% 

Get command admin flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 07-13-2018 , 07:36   Get command admin flags
Reply With Quote #1

I'm looking for a way to get admin flags of a SourceMod command, such as sm_kick.

GetCommandFlags provides only FCVAR_* flags (similar to GetConVarFlags), 0 for any SM commands.
GetCommandOverride seems to provide the flags only when the command is overridden.

The only way I've found so far is by using ReadCommandIterator, however, I would have to iterate every command each time I want to check. Or perhaps there is a way to get the handle of a specific command?

Thank you in advance.
Phil25 is offline
Send a message via Skype™ to Phil25
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-13-2018 , 08:15   Re: Get command admin flags
Reply With Quote #2

Quote:
Originally Posted by Phil25 View Post
I'm looking for a way to get admin flags of a SourceMod command, such as sm_kick.

GetCommandFlags provides only FCVAR_* flags (similar to GetConVarFlags), 0 for any SM commands.
GetCommandOverride seems to provide the flags only when the command is overridden.

The only way I've found so far is by using ReadCommandIterator, however, I would have to iterate every command each time I want to check. Or perhaps there is a way to get the handle of a specific command?

Thank you in advance.
Iterator is best, use it.
__________________
Accepting private work.

myGaming unique coded versus no VIP no premium.
eyal282 is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 07-13-2018 , 08:38   Re: Get command admin flags
Reply With Quote #3

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(eFlagtrue);

    
bool bResult CheckAccess(hAdminsCmd0false);
    
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 View Post
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?
Phil25 is offline
Send a message via Skype™ to Phil25
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 07-14-2018 , 01:14   Re: Get command admin flags
Reply With Quote #4

I don't think there's a function to directly do what you want, though one could be added.

That said, flags aren't really useful if you're building a more featureful admin system. There's only so many flags available but there will be many commands (as you say, you have 400+). Groups and overrides may be the way to go, depending on what you're really trying to do.
Fyren is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:48.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode