[HELP] DButton do a clientside console command


include ( "shared.lua" )

net.Receive( "f2menu", function()
	if( !frame ) then
	local frame = vgui.Create( "DFrame" )
	frame:SetSize( 1600, 1050 )
	frame:SetVisible( true )
	frame:MakePopup()
	frame:SetTitle( "Mayor Menu" )
	frame:SetDeleteOnClose( true )
	frame:SetDraggable( false )
	frame:Center()
	frame:ShowCloseButton( true )
	frame.Paint = function( self, w, h )
		draw.RoundedBox(0, 0, 0, w, h, Color( 156, 156, 156, 230) )
	
	end
	
	local x,y = frame:GetSize()
	
	local button = vgui.Create( "DButton", frame )
	button:SetText( "Close" )
	button:SetSize( 50, 30 )
	button:SetPos( x - 50, 0 )
	button.DoClick = function()
		frame:Close()
	end 
	
	
	local button = vgui.Create( "DButton", frame )
	button:SetText( "Initiate Lockdown" )
	button:SetSize( 100, 50 )
	button:SetPos( 100, 100 )
	button.DoClick = function()
		
	end 
	
	end
	
	
	
	
	
	
end)

So basically for the button that says Initiate Lockdown, I want when the person presses it, it will say /lockdown in the chat.
This is a mayor menu for darkrp.
I need help on this, thank you!

[lua]button:SetConsoleCommand(“say”, “/lockdown”)[/lua]

I need it to be a chat message, for example say /lockdown
Not two arguments just one.

No, you don’t. Go in game and you will see it is right.

How do I turn all of my scripts into an addon? I can’t make a new thread and I assume you know how to.

[editline]6th September 2016[/editline]

How do I turn all of my scripts into an addon? I can’t make a new thread and I assume you know how to.

sannys is correct but didnt help to know where to put the line of code


local button = vgui.Create( "<span class="highlight">DButton</span>", frame )
	button:SetText( "Initiate Lockdown" )
	button:SetSize( 100, 50 )
	button:SetPos( 100, 100 )
	button.DoClick = function()
                button:SetConsoleCommand("say", "/lockdown")
		
	end 
	
	end
	
	
	
	
	
	
end)



include "shared.lua"

net.Receive( "f2menu", function()
	if !frame then
		local frame = vgui.Create( "DFrame" )
		frame:SetSize( 1600, 1050 )
		frame:SetVisible( true )
		frame:MakePopup()
		frame:SetTitle( "Mayor Menu" )
		frame:SetDeleteOnClose( true )
		frame:SetDraggable( false )
		frame:Center()
		frame:ShowCloseButton( true )
		frame.Paint = function( self, w, h )
			draw.RoundedBox(0, 0, 0, w, h, Color( 156, 156, 156, 230) )
		end
	
		local x,y = frame:GetSize()
	
		local button = vgui.Create( "DButton", frame )
		button:SetText( "Close" )
		button:SetSize( 50, 30 )
		button:SetPos( x - 50, 0 )
		button.DoClick = function()
			frame:Close()
		end 
	
		local button = vgui.Create( "DButton", frame )
		button:SetText( "Initiate Lockdown" )
		button:SetSize( 100, 50 )
		button:SetPos( 100, 100 )
		button.DoClick = function()
			RunConsoleCommand( "say", "/lockdown" )
		end 
	end
end)


Should work, try it