Difference between revisions of "Custom Admin Menu (SourceMod)"

From AlliedModders Wiki
Jump to: navigation, search
(Extra Uses)
 
(41 intermediate revisions by 7 users not shown)
Line 1: Line 1:
NB: This is currently implemented as a third party plugin ‘SM Super Menu’ and will become available as part of core package with version 1.1
+
{{Languages|Custom Admin Menu (SourceMod)}}
 
 
 
==Introduction==
 
==Introduction==
 +
The custom menu feature allows server admins to add new items to the SourceMod admin menu. It is designed to be used as a complement to plugins adding themselves to the menu. For more information see [[Admin Menu (SourceMod Scripting)]].
  
Use as a complement to plugins adding themselves to the menu *link*
+
Admins configure their menu using the config file (sourcemod/configs/adminmenu_custom.txt) and this is generated into a set of items and categories for the admin menu when the server starts.
What it does.
 
  
 
==Parameter List==
 
==Parameter List==
 +
 +
These are all the parameters that can be specified to configure your menu. Most are optional and have a default value if they are not found. See the [[#Example Command|Example Command]] and/or the attached [[#Example Files|Example Files]] for information on how to lay out your config file.
  
 
*cmd - command to be executed (#1,#2 etc for parameters - no limit on these) Use @num to have the parameter sent without being surrounded by "quotes"
 
*cmd - command to be executed (#1,#2 etc for parameters - no limit on these) Use @num to have the parameter sent without being surrounded by "quotes"
 
*admin - admin level required to access the command - see [[#Admin Levels|Admin Levels]]
 
*admin - admin level required to access the command - see [[#Admin Levels|Admin Levels]]
*execute - 'server' or 'player' - selects whether to execute as a client command or server command
+
*execute - 'server' or 'player' - selects whether to execute as a client command or server command - defaults to 'player'
 
*1 - Information about parameter 1 (#1) - You need as many of these as you have parameters
 
*1 - Information about parameter 1 (#1) - You need as many of these as you have parameters
 
**type - defaults to 'list' if not provided
 
**type - defaults to 'list' if not provided
Line 19: Line 20:
 
***'mapcycle' - Auto filled with the contents of your mapcycle file
 
***'mapcycle' - Auto filled with the contents of your mapcycle file
 
***'onoff' - On or Off menu that sends the numbers 1/0 (good for cvars etc)
 
***'onoff' - On or Off menu that sends the numbers 1/0 (good for cvars etc)
**path - Only required for type mapcycle. Path (including file name and extension) to the file containing a list of maps (straight text formatting like mapcycle.txt)
+
**path - Only required for type mapcycle. Path (including file name and extension) to the file containing a list of maps (straight text formatting like mapcycle.txt) - defaults to 'mapcycle.txt'
**method - 'name', 'steamid', 'userid', 'clientid' - only needed for groupplayer/player menus - defaults to name
+
**method - 'name', 'steamid', 'userid', 'userid2' (doesn't prepend the '#'), 'clientid', 'ip' - only needed for groupplayer/player menus - defaults to name
 
**title - To be shown for the parameter selection menu (optional)
 
**title - To be shown for the parameter selection menu (optional)
 
**1-x - List parameters - only needed for 'list' type parameters
 
**1-x - List parameters - only needed for 'list' type parameters
Line 39: Line 40:
 
"1"
 
"1"
 
{
 
{
"type" "teamplayer"
+
"type" "groupplayer"
 
"method" "name"
 
"method" "name"
 
"title" "Player/Team to Edit"
 
"title" "Player/Team to Edit"
Line 66: Line 67:
 
}
 
}
 
</pawn>
 
</pawn>
Using the above as the contents of your menu.ini config file would create a new category option in the admin menu called 'Fun Commands'.
+
Using the above as the contents of your adminmenu_custom.txt config file would create a new category option in the admin menu called 'Fun Commands'.
 
*This category would contain an option called : "Set Player Speed".
 
*This category would contain an option called : "Set Player Speed".
 
*Selecting it would prompt another menu titled: "Player/Team to Edit" containing a list of Groups and Player Names.
 
*Selecting it would prompt another menu titled: "Player/Team to Edit" containing a list of Groups and Player Names.
 
*Selecting one of these would prompt a second menu titled "Speed Multiplier".
 
*Selecting one of these would prompt a second menu titled "Speed Multiplier".
 
*List of options like "Normal", "80%" etc.
 
*List of options like "Normal", "80%" etc.
*Example command sent if the user selected "Double" (through the player using fakeclientcommand)  - "sm_speed @CT 2.0"
+
*Example command sent if the user selected "Double" (through the player using FakeClientCommand)  - 'sm_speed "@CT" 2.0'
 +
 
 +
NB: You can use \ as an escape character. So \" will let you add quotes to your strings.
  
 
==Admin Levels==
 
==Admin Levels==
  
All 'admin' types now require a string command name. This command can be already existing (sm_ban) or completely imaginary (reallyweirdcommandnamethatdoesntexist).
+
All 'admin' types now require a string command name. This command can be already existing (sm_ban) or completely imaginary (onlycrabscanusethis).
 
 
If the command exists that section (or list option) will require the exact same access level as that command (including any overrides you have specified).
+
If the command exists that section (or list option) will require the exact same access level as that command (including any overrides you have specified).<br>
Eg you use sm_ban as the admin level for a submenu. Admins will require the 'ban' flag to access this. However if you have overridden sm_ban in one of your lower groups ("override" "allow" - in admin_groups.cfg). This group will also have access.
+
E.g. You use sm_ban as the admin level for a submenu, so anyone that can access sm_ban will also be able to access this menu option (By default this is admins with the 'ban' flag). However if you have overridden sm_ban in one of your lower groups ("override" "allow" - in admin_groups.cfg). This group will also have access.
 
 
 
If the command doesn't exist you will need to add it to your overrides sections as if it was a normal command. This can be done in admin_overrides.cfg (to assign flag letters to this command),
 
If the command doesn't exist you will need to add it to your overrides sections as if it was a normal command. This can be done in admin_overrides.cfg (to assign flag letters to this command),
 
and/or in admin_groups.cfg (to give access to the command to a specified group or remove it from a group even though they have the flag)
 
and/or in admin_groups.cfg (to give access to the command to a specified group or remove it from a group even though they have the flag)
 +
 +
If no admin level is specified for a base command it will default to the first argument of the "cmd" string. For example having
 +
<pawn>
 +
"cmd" "sm_ban #1 #2"
 +
</pawn>
 +
 +
would have a default admin override string of 'sm_ban'
 
 
 
For more information, see [[Overriding Command Access (SourceMod)|Overriding Command Access]]
 
For more information, see [[Overriding Command Access (SourceMod)|Overriding Command Access]]
Line 87: Line 97:
 
==Group Submenus==
 
==Group Submenus==
  
Types 'group' and 'groupplayer' auto-add pre configured options to the menu. These options are configured using sourcemod/configs/adminmenu_grouping.txt
+
Types 'group' and 'groupplayer' auto-add pre configured options to the menu. These options are configured using sourcemod/configs/adminmenu_grouping.txt
  
They are generally used to provide common commands like '@all' , '@t' etc to your menus.
+
They are generally used to provide common commands like '@all' , '@t' etc to your menus.
  
 
==Categories==
 
==Categories==
  
If you wish to add items to an existing category you will need to specify it’s internal name. For the three categories provided by SourceMod base these are:
+
If you wish to add items to an existing SourceMod category you will need to specify it’s internal name within the "commands" group. The three categories provided by SourceMod are:
  
 
*PlayerCommands
 
*PlayerCommands
Line 99: Line 109:
 
*VotingCommands
 
*VotingCommands
  
 +
==Sorting==
 +
Categories and items added using the dynamic menu can be sorted in the same way as normal items. For more information, see [[Admin Menu Configuration (SourceMod)|Admin Menu Configuration]]
 +
 +
You need to specify the name you gave the command in your configuration file. For the provided example:
 +
<pawn>
 +
"item" "Set Player Speed"
 +
</pawn>
 
==Extra Uses==
 
==Extra Uses==
An example of using the dynamic menu to it's full potential: Giving admins access to some cvars while not letting them have general 'sm_cvar' access.
+
An example of using the dynamic menu to its full potential: Giving admins access to some cvars while not letting them have general 'sm_cvar' access.
  
Add the cvar you want to make available using the command directly and set the 'execute' parameter.
+
Add the cvar you want to make available using the command directly and set the 'execute' parameter to 'server'
 
<pawn>
 
<pawn>
 
"cmd" "mp_friendlyfire #1"
 
"cmd" "mp_friendlyfire #1"
Line 108: Line 125:
 
"admin" "sm_kick"
 
"admin" "sm_kick"
 
</pawn>
 
</pawn>
This fires the command directly through rcon so there are no admin pre-requisites (other than what you set using the 'admin' parameter). This method can be used to create a list of commonly used (and low impact) cvars that your lower admins can change at will, without giving them access to everything. The same method works for rcon commands.
+
This fires the command directly through rcon so it bypasses the normal SourceMod admin requirements and only checks what you set using the 'admin' parameter. This method can be used to create a list of commonly used (and low impact) cvars that your lower admins can change at will, without giving them access to everything. The same method works for rcon commands.
  
 
==Example Files==
 
==Example Files==
Set up for super commands
+
 
 +
Example adminmenu_custom.txt setup with Super Commands examples:<br>
 +
[http://users.alliedmods.net/~pred/supercmdsmenu.ini adminmenu_custom.txt]<br>
 +
<br>
 +
A Full example setup thanks to uE|Tekniqal:<br>
 +
[http://users.alliedmods.net/~pred/smsuper.ini adminmenu_custom.txt]<br>
 +
[http://users.alliedmods.net/~pred/admin_overrides.cfg admin_overrides.cfg]<br>
 +
[http://users.alliedmods.net/~pred/admin_groups.cfg admin_groups.cfg]<br>
 +
 
 +
 
 +
[[Category:SourceMod Documentation]]

Latest revision as of 11:50, 10 September 2019

Language: English  • русский

Introduction

The custom menu feature allows server admins to add new items to the SourceMod admin menu. It is designed to be used as a complement to plugins adding themselves to the menu. For more information see Admin Menu (SourceMod Scripting).

Admins configure their menu using the config file (sourcemod/configs/adminmenu_custom.txt) and this is generated into a set of items and categories for the admin menu when the server starts.

Parameter List

These are all the parameters that can be specified to configure your menu. Most are optional and have a default value if they are not found. See the Example Command and/or the attached Example Files for information on how to lay out your config file.

  • cmd - command to be executed (#1,#2 etc for parameters - no limit on these) Use @num to have the parameter sent without being surrounded by "quotes"
  • admin - admin level required to access the command - see Admin Levels
  • execute - 'server' or 'player' - selects whether to execute as a client command or server command - defaults to 'player'
  • 1 - Information about parameter 1 (#1) - You need as many of these as you have parameters
    • type - defaults to 'list' if not provided
      • 'groupplayer' - List of Groups + connected player
      • 'group' - List of Groups
      • 'player' - List of players
      • 'list' - Custom Defined list of Options
      • 'mapcycle' - Auto filled with the contents of your mapcycle file
      • 'onoff' - On or Off menu that sends the numbers 1/0 (good for cvars etc)
    • path - Only required for type mapcycle. Path (including file name and extension) to the file containing a list of maps (straight text formatting like mapcycle.txt) - defaults to 'mapcycle.txt'
    • method - 'name', 'steamid', 'userid', 'userid2' (doesn't prepend the '#'), 'clientid', 'ip' - only needed for groupplayer/player menus - defaults to name
    • title - To be shown for the parameter selection menu (optional)
    • 1-x - List parameters - only needed for 'list' type parameters
    • 1.-x. - Text to be shown for parameter - only needed for 'list' type parameters (optional, above will be used as text if ommited)
    • 1* - x* - Admin level required to see this option (same as the rest of the admin types)

Example Command

"Commands"
{
	"Fun Commands"
	{
		"Set Player Speed"
		{
			"cmd"			"sm_speed #1 @2"
			"admin"			"sm_kick"
			"execute"		"player"
			"1"
			{
				"type" 		"groupplayer"
				"method"	"name"
				"title"		"Player/Team to Edit"
 
			}
			"2"
			{
				"type" 		"list"
				"title"		"Speed Multiplier"
				"1"		"1.0"
				"1."		"Normal"
				"2"		"0.8"
				"2."		"80%"
				"3"		"0.5"
				"3."		"Half"
				"4"		"1.5"
				"4."		"50% Boost"
				"5"		"2.0"
				"5."		"Double"
				"5*"		"sm_ban" 
				//restrict the double option to admins who have access to the 'sm_ban' override
			}
 
		}
	}
}

Using the above as the contents of your adminmenu_custom.txt config file would create a new category option in the admin menu called 'Fun Commands'.

  • This category would contain an option called : "Set Player Speed".
  • Selecting it would prompt another menu titled: "Player/Team to Edit" containing a list of Groups and Player Names.
  • Selecting one of these would prompt a second menu titled "Speed Multiplier".
  • List of options like "Normal", "80%" etc.
  • Example command sent if the user selected "Double" (through the player using FakeClientCommand) - 'sm_speed "@CT" 2.0'

NB: You can use \ as an escape character. So \" will let you add quotes to your strings.

Admin Levels

All 'admin' types now require a string command name. This command can be already existing (sm_ban) or completely imaginary (onlycrabscanusethis).

If the command exists that section (or list option) will require the exact same access level as that command (including any overrides you have specified).
E.g. You use sm_ban as the admin level for a submenu, so anyone that can access sm_ban will also be able to access this menu option (By default this is admins with the 'ban' flag). However if you have overridden sm_ban in one of your lower groups ("override" "allow" - in admin_groups.cfg). This group will also have access.

If the command doesn't exist you will need to add it to your overrides sections as if it was a normal command. This can be done in admin_overrides.cfg (to assign flag letters to this command), and/or in admin_groups.cfg (to give access to the command to a specified group or remove it from a group even though they have the flag)

If no admin level is specified for a base command it will default to the first argument of the "cmd" string. For example having

"cmd"		"sm_ban #1 #2"

would have a default admin override string of 'sm_ban'

For more information, see Overriding Command Access

Group Submenus

Types 'group' and 'groupplayer' auto-add pre configured options to the menu. These options are configured using sourcemod/configs/adminmenu_grouping.txt

They are generally used to provide common commands like '@all' , '@t' etc to your menus.

Categories

If you wish to add items to an existing SourceMod category you will need to specify it’s internal name within the "commands" group. The three categories provided by SourceMod are:

  • PlayerCommands
  • ServerCommands
  • VotingCommands

Sorting

Categories and items added using the dynamic menu can be sorted in the same way as normal items. For more information, see Admin Menu Configuration

You need to specify the name you gave the command in your configuration file. For the provided example:

"item"	"Set Player Speed"

Extra Uses

An example of using the dynamic menu to its full potential: Giving admins access to some cvars while not letting them have general 'sm_cvar' access.

Add the cvar you want to make available using the command directly and set the 'execute' parameter to 'server'

"cmd"		"mp_friendlyfire #1"
"execute"	"server"
"admin"		"sm_kick"

This fires the command directly through rcon so it bypasses the normal SourceMod admin requirements and only checks what you set using the 'admin' parameter. This method can be used to create a list of commonly used (and low impact) cvars that your lower admins can change at will, without giving them access to everything. The same method works for rcon commands.

Example Files

Example adminmenu_custom.txt setup with Super Commands examples:
adminmenu_custom.txt

A Full example setup thanks to uE|Tekniqal:
adminmenu_custom.txt
admin_overrides.cfg
admin_groups.cfg