Derma Beta

I have currently gotten into the task of making derma menus. I have came across many files and plan to use this thread to find my answers. My first question is listed below:

  1. How do I add a space in my commands? For example when I press this button:

  local DermaButton = vgui.Create( "DButton" )
  DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel"
  DermaButton:SetText( "ULX Main Menu" )
  DermaButton:SetPos( 25, 50 )
  DermaButton:SetSize( 100, 25 )
  DermaButton.DoClick = function ()
   RunConsoleCommand( "ulx menu" ) // What happens when you press the button
  end 

I get this console error :
RunConsoleCommand: Command has invalid characters! (ulx menu (’ '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.

How can I add spaces in my argument?

Whenever you’re uncertain about how to use a function your first stop should always be the wiki. :smile:
Your answer is right here : **[G.RunConsoleCommand

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=G.RunConsoleCommand)**

Thank you very much Crazy Quebec lol. The only reason I didn’t check there is becuase I don’t know where to look for this stuff.

[editline]05:06AM[/editline]

Okay next issue. Is there any way I can get it so I can type in a box, then hit like submit and it will submit that variable? For example. I want it to be a ban line. So what I would do is have a rectangle and you can type their name, then there would be a smaller box right below that and you would put the time, followed by a reason box, then after that there would be a ban button. Once the ban button was pressed, this would placed into console
ulx ban “name put in first box” “time” “reason”
is that possible? Again, I searched that wiki and couldn’t seem to find anything on the subject.

There are various ways of doing such a thing, a useful widget is the DTextEntry, place that on your gui somewhere and in the button’s DoClick function you can use the DTextEntry:GetValue() as a parameter, which will return the text you entered into the box.

Okay fish, I tried that but its not working
It put a text box in the top left corner of my screen.

Also how do I put things in certain tabs? I have the tabs set but I can’t make it so the buttons or anything is on the tab.

When creating them parent them to a panel which you can add as a tab.

how do I parent them?

Two ways, either put the parent as the second parameter to vgui.Create like this
local frame = vgui.Create(“DFrame”)
local button = vgui.Create(“DFrame”, button)
or you can use the SetParent method
local frame = vgui.Create(“DFrame”)
local button = vgui.Create(“DButton”)
button:SetParent(frame)

Wow this is all confusing to me. Can anyone unravel this messy code I have? Everything is wrong. All the ulx related things, server side related thigns go in the server tab. Kill goes in the first tab. Please help…


local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 400, 450 )
DermaPanel:SetTitle( "The Avenger's Test Derma BETA STAGE01" ) // Name of Frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) //Can the player drag the frame /True/False
DermaPanel:ShowCloseButton( true ) //Show the X (Close button) /True/False
DermaPanel:MakePopup()

local PropertySheet = vgui.Create( "DFrame", DPropertySheet )
PropertySheet:SetParent( DermaPanel )
PropertySheet:SetPos( 5, 30 )
PropertySheet:SetSize( 390, 350 )
local frame = vgui.Create("DFrame")
local SheetItemOne = vgui.Create( "DFrame", DCheckBoxLabel )
SheetItemOne:SetText( "Use Props?" )
SheetItemOne:SetConVar( "some_convar" )
SheetItemOne:SetValue( 1 )
SheetItemOne:SizeToContents()

  local DermaButton = vgui.Create( "DFrame", button )
  DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel"
  DermaButton:SetText( "Kill" )
  DermaButton:SetPos( 10, 75 )
  DermaButton:SetSize( 100, 25 )
  DermaButton.DoClick = function ()
   RunConsoleCommand( "kill" ) // What happens when you press the button
  end 
  
    local DermaButton = vgui.Create( "DButton" )
  DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel"
  DermaButton:SetText( "ULX Main Menu" )
  DermaButton:SetPos( 110, 75 )
  DermaButton:SetSize( 100, 25 )
  DermaButton.DoClick = function ()
   RunConsoleCommand( "ulx", "menu" ) // What happens when you press the button
  end 
 
local SheetItemTwo = vgui.Create( "DCheckBoxLabel" )
SheetItemTwo:SetText( "Use SENTs?" )
SheetItemTwo:SetConVar( "some_convar" )
SheetItemTwo:SetValue( 1 )
SheetItemTwo:SizeToContents()

local DermaButton = vgui.Create( "DButton" )
  DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel"
  DermaButton:SetText( "ULX Main Menu" )
  DermaButton:SetPos( 110, 75 )
  DermaButton:SetSize( 100, 25 )
  DermaButton.DoClick = function ()
   RunConsoleCommand( "ulx", "menu" ) // What happens when you press the button
  end 
  
  local DermaButton = vgui.Create( "DButton" )
  DermaButton:SetParent( DermaPanel ) // Set parent to our "DermaPanel"
  DermaButton:SetText( "RP_Own" )
  DermaButton:SetPos( 110, 100 )
  DermaButton:SetSize( 100, 25 )
  DermaButton.DoClick = function ()
   RunConsoleCommand( "rp_own" ) // What happens when you press the button
  end 
 
 myText = vgui.Create("DTextEntry", myParent)
myText:SetText("(Name)")
 --The following has been changed from "myText:GetText()" to "myText:GetValue()"
myText.OnEnter = function() Msg("rp_addowner " .. myText:GetValue() .. "/n") end
 
PropertySheet:AddSheet( "Default Commands", SheetItemOne, "gui/silkicons/user", false, false, "Default Client Side Commands" )
PropertySheet:AddSheet( "Default Settings", SheetItemTwo, "gui/silkicons/group", false, false, "Default Listen Server Settings" ) 

myText = vgui.Create("DTextEntry", myParent)
myText:SetText("Initial Value")
 --The following has been changed from "myText:GetText()" to "myText:GetValue()"
myText.OnEnter = function() Msg("rp_addowner" .. myText:GetValue() .. "/n") end

   concommand.Add( "minmenu", DermaPanel )
 usermessage.Hook( "call_vgui", ShowTeamMenu )