Garry's Mod Wiki

DButton:SetConsoleCommand

  DButton:SetConsoleCommand( string command, string args )

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
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() )