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

From AlliedModders Wiki
Jump to: navigation, search
m (Parameter List)
Line 138: Line 138:
  
 
[[Category:SourceMod Documentation]]
 
[[Category:SourceMod Documentation]]
 +
 +
{{LanguageSwitch}}

Revision as of 05:10, 30 August 2013

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

Warning: This template (and by extension, language format) should not be used, any pages using it should be switched to Template:Languages

View this page in:  English  Russian  简体中文(Simplified Chinese)