Skip to content

Block Hidden Commands from Help Command - #1831

Merged
peace-maker merged 1 commit into
alliedmodders:masterfrom
Batfoxkid:patch-1
Dec 1, 2022
Merged

peace-maker merged 1 commit into
alliedmodders:masterfrom
Batfoxkid:patch-1

Conversation

@Batfoxkid

Copy link
Copy Markdown
Contributor

Allows using FCVAR_HIDDEN to block commands from appearing in sm_help and sm_searchcmd which helps with creating alias to commands without filling up the list with those aliases.

For example:

RegAdminCmd("sm_setmyperk", MyCommand, ADMFLAG_CHEATS);
RegAdminCmd("sm_setmyperks", MyCommand, ADMFLAG_CHEATS, _, FCVAR_HIDDEN);

RegConsoleCmd("ff2_boss", MyCommand);
RegConsoleCmd("ff2boss", MyCommand, _, FCVAR_HIDDEN);

Allows using `FCVAR_HIDDEN` to block commands from appearing in `sm_help` and `sm_searchcmd` which helps with creating alias to commands without filling up the list with those aliases.

For example:
```sourcepawn
RegAdminCmd("sm_setmyperk", MyCommand, ADMFLAG_CHEATS);
RegAdminCmd("sm_setmyperks", MyCommand, ADMFLAG_CHEATS, _, FCVAR_HIDDEN);

RegConsoleCmd("ff2_boss", MyCommand);
RegConsoleCmd("ff2boss", MyCommand, _, FCVAR_HIDDEN);
```
Comment thread plugins/adminhelp.sp
cmdIter.GetDescription(desc, sizeof(desc));

if ((StrContains(name, arg, false) != -1) && CheckCommandAccess(client, name, cmdIter.Flags))
if ((StrContains(name, arg, false) != -1) && ((FindConVar(name).Flags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't cmdIter.Flags already give you the flags, why the additional lookup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't cmdIter.Flags already give you the flags, why the additional lookup?

That is for admin flags and not command flags.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be a good idea to add it to the iterator before making this change - we don't need workarounds here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather add the convar flags property in a seperate PR and switch this over? It doesn't really fit the goal of this one.

@peace-maker peace-maker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a nice non-intrusive addition to the help menu. All commands should be visible by default and allowing you to hide aliases this way does help the readability of the help menu.

@peace-maker
peace-maker merged commit ed662dc into alliedmodders:master Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants