• Why won't my DPanel open?
    1 replies, posted
So my DPanel won't open for some reason... Here's my code: Init.lua: [CODE]util.AddNetworkString( 'OpenIt' ) hook.Add( 'ShowSpare2', 'StartitUP', function( v ) net.Start( 'OpenIt' ) net.Send( v ) end )[/CODE] Cl_init.lua: [CODE]net.Receive( 'OpenIt', function() local base = vgui.Create( 'DFrame' ) base:SetSize( 470, 235 ) base:Center() base:ShowCloseButton( true ) base:MakePopup() base:SetDraggable( false ) base:SetTitle( 'Admin Help' ) function base:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0,0, 0 ) ) surface.SetDrawColor( 33, 255, 0 ) surface.DrawOutlinedRect( 1, 1, w-2, h-2 ) end local button = vgui.Create( 'DButton' ) button:SetParent( base ) button:SetSize( 150, 100 ) button:SetPos( 5, 26 ) button:SetText( 'RDM' ) button.DoClick = function() function button:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 33, 255, 0 ) ) end RunConsoleCommand( "say", "`Help! I have been RDMed!" ) end local button2 = vgui.Create( 'DButton' ) button2:SetParent( base ) button2:SetSize( 150, 100 ) button2:SetPos( 160, 26 ) button2:SetText( 'RDA' ) button2.DoClick = function() function button2:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 33, 255, 0 ) ) end RunConsoleCommand( "say", "`Help! I have been RDAed!" ) end local button3 = vgui.Create( 'DButton' ) button3:SetParent( base ) button3:SetSize( 150, 100 ) button3:SetPos( 315, 26 ) button3:SetText( 'NLR' ) button3.DoClick = function() function button3:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 33, 255, 0 ) ) end RunConsoleCommand( "say", "`Help! This person is breaking New Life Rule!" ) end local button4 = vgui.Create( 'DButton' ) button4:SetParent( base ) button4:SetSize( 150, 100 ) button4:SetPos( 5, 130 ) button4:SetText( 'Propkill' ) button4.DoClick = function() function button4:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 33, 255, 0 ) ) end RunConsoleCommand( "say", "`Help! This person is Prop-Killing!" ) end local button5 = vgui.Create( 'DButton' ) button5:SetParent( base ) button5:SetSize( 150, 100 ) button5:SetPos( 160, 130 ) button5:SetText( 'Propblock' ) button5.DoClick = function() function button5:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 33, 255, 0 ) ) end RunConsoleCommand( "say", "`Help! This person is Prop-Blocking!" ) end local button6 = vgui.Create( 'DButton' ) button6:SetParent( base ) button6:SetSize( 150, 100 ) button6:SetPos( 315, 130 ) button6:SetText( 'Minge' ) button6.DoClick = function() function button6:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 33, 255, 0 ) ) end RunConsoleCommand( "say", "`Help! This person is Mingeing!" ) end end )[/CODE]
You can avoid using "SetParent" by just doing: vgui.Create( element, parent ); You've got the argument correct, make sure that the hook was added / is being run on the server: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/open_vgui_based_on_keypress.lua.html[/url] Are there any errors? Comment out all code except the first element that is created, the base window/panel. See if anything happens; try without the paint code. If you want to be able to auto-refresh easily in the event of a typo ( to remove stuck vgui windows from screen ), add this to your addons: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua[/url] and type clearvgui when needed.
Sorry, you need to Log In to post a reply to this thread.