• Print

Author Topic: Menu Help  (Read 4824 times)

0 Members and 1 Guest are viewing this topic.

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Menu Help
« on: February 19, 2014, 04:22:23 pm »
could someone give me an example of a menu i have coded one that is not for ulx tht i want to use for a broadcast type thing that basically tells the server what you type but it doesnt work the code i made is
Code: Lua
  1. function Menu()
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "Menu" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(138,62,189,150)
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(122,122,122,255)
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160)
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.onEnter = function()
  24.                 ply:ConCommand("ulx tsay "..TextEntry:GetValue())
  25.                 BackGround:SetVisible( false )
  26.         end
  27. end
  28. concommand.Add( "open_menu", Menu )
  29.  
« Last Edit: February 21, 2014, 12:48:20 pm by lampman13 »

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: Menu Help
« Reply #1 on: February 19, 2014, 04:37:56 pm »
ok i fixed my problem but now it doesnt do the command i have it so it comes in tsay for the time being but it doens seem to be working
Code: Lua
  1. function Menu()
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "Menu" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(138, 62, 189, 150))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(122, 122, 122, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.onEnter = function()
  24.                 ply:ConCommand("ulx tsay "..TextEntry:GetValue())
  25.                 BackGround:SetVisible( false )
  26.         end
  27. end
  28. concommand.Add("open_menu",Menu)
« Last Edit: February 21, 2014, 12:48:56 pm by lampman13 »

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Menu Help
« Reply #2 on: February 19, 2014, 04:52:46 pm »
It's OnEnter not onEnter. Also try GetText() instead of GetValue(). And instead of SetVisible( false )
just do Close()
« Last Edit: February 19, 2014, 04:57:00 pm by Cobalt »

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: Menu Help
« Reply #3 on: February 19, 2014, 06:49:33 pm »
thank you so much for a response i will try now

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: Menu Help
« Reply #4 on: February 19, 2014, 06:55:05 pm »
it works uhm could you help me with something else to i dont know how to make something display in the middle of the screen with that like they would open the menu and it would display the text in the middle topish of the screen in a box maybe?

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Menu Help
« Reply #5 on: February 19, 2014, 08:49:26 pm »
Use Panel:Center()

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: Menu Help
« Reply #6 on: February 20, 2014, 12:36:03 pm »
yeah but i mean like it would make a box in the topish of the screen that said what the text you entered said if that makes sense xD

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: Menu Help
« Reply #7 on: February 20, 2014, 02:10:29 pm »
ok i have changed it so it displays a text in the center of the screen but it doesn work it broke it
Code: Lua
  1. function Menu()
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "Menu" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(138, 62, 189, 150))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(122, 122, 122, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.OnEnter = function()
  24.                 PrintMessage( HUD_PRINTCENTER,..TextEntry:GetText() )
  25.                 BackGround:SetVisible()
  26.         end
  27. end
  28. concommand.Add("open_menu",Menu)
  29.  
« Last Edit: February 21, 2014, 12:49:14 pm by lampman13 »

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: Menu Help
« Reply #8 on: February 20, 2014, 05:58:32 pm »
no one can help?

  • Print