Garry's Mod Wiki

DButton:SetConsoleCommand

  DButton:SetConsoleCommand( string command, string args = nil )

Description

Sets a console command to be called when the button is clicked.

This overrides the button's DoClick method.

Arguments

1 string command
The console command to be called.
2 string args = nil
The arguments for the command.

Example

Creates a button that makes the player say their name.

local button = vgui.Create( "DButton" ) button:SetSize( 100, 35 ) button:SetText( "Say your nickname" ) button:Center() button:MakePopup() button:SetConsoleCommand( "say", LocalPlayer():Nick() )