spawnmenu.AddToolMenuOption

From Garry's Mod
Jump to: navigation, search
 spawnmenu.AddToolMenuOption( )

Contents

Description

Adds an option to the right side of the spawnmenu

Arguments

string tab

The spawnmenu tab to add into (for example "Utilities")

Arguments

string category

The category to add into (for example "Admin")

Arguments

string class

Unique identifier of option to add

Arguments

string name

The nice name of item

Arguments

string cmd

Command to execute when the item is selected

Arguments

string config

Config name, used in older versions to load tool settings UI from a file. No longer works.

This feature is deprecated.
You should avoid using it as it may be removed in a future version.

Arguments

function cpanel

A function to build the context panel. The function has one argument:

  • Panel pnl - A DForm that will be shown in the context menu

Arguments

table table={}

Allows to override the table that will be added to the tool list. Some of the fields will be overwritten by this function.

Examples

Example

Adds a new option to the menu with a slider to change the gravity

hook.Add( "PopulateToolMenu", "CustomMenuSettings", function()
	spawnmenu.AddToolMenuOption( "Utilities", "Stuff", "Custom_Menu", "My Custom Menu", "", "", function( panel )
		panel:ClearControls()
		panel:NumSlider( "Gravity", "sv_gravity", 0, 600 )
		-- Add stuff here
	end )
end )

Output:

addtoolmenuoption.png
Personal tools
Navigation