Garry's Mod Wiki

Revision Difference

DButton:SetConsoleCommand#514190

<function name="SetConsoleCommand" parent="DButton" type="panelfunc">⤶ <ispanel>yes</ispanel>⤶ <description>⤶ Sets a console command to be called when the button is clicked.⤶ ⤶ This overrides the button's `DoClick` method.⤶ </description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="command" type="string">The console command to be called.</arg>⤶ <arg name="args" type="string">The arguments for the command.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Creates a button that makes the player say their name.</description>⤶ <code>⤶ local button = vgui.Create( "DButton" )⤶ button:SetSize( 100, 35 )⤶ button:SetText( "Say your nickname" )⤶ button:Center()⤶ button:MakePopup()⤶ button:SetConsoleCommand( "say", LocalPlayer():Nick() )⤶ </code>⤶ ⤶ </example>