Removing the vgui

include( “shared.lua” )

function set_team()

frame = vgui.Create( “DFrame” )
frame:SetPos( 100, ScrH() / 2 )
frame:SetSize( 200, 210 )
frame:SetTitle( “Pick Your Team” )
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()

team_1 = vgui.Create( “DButton”, frame )
team_1:SetPos( 30, 30 )
team_1:SetSize( 100, 50 )
team_1:SetText( “Guards” )
team_1.DoClick = function()

 RunConsoleCommand( "team_1" ) 

end

team_2 = vgui.Create( “DButton”, frame )
team_2:SetPos( 30, 85 )
team_2:SetSize( 100, 50 )
team_2:SetText( “Prisoners” )
team_2.DoClick = function()

 RunConsoleCommand( "team_2" ) 

end

end
concommand.Add( “team_menu”, set_team )

How do i make the menu disappear after clicking on it, and how do i set f2 to bring the menu back up?

server side
[lua]
function GM:ShowTeam(ply)
umsg.Start(“Showf2”,ply)
umsg.End()
[/lua]
ClientSide
[lua]

include( “shared.lua” )

function set_team()
frame = vgui.Create( “DFrame” )
frame:SetPos( 100, ScrH() / 2 )
frame:SetSize( 200, 210 )
frame:SetTitle( “Pick Your Team” )
frame:SetVisible( true )
frame:SetDraggable( false )
frame:ShowCloseButton( true )
frame:MakePopup()

team_1 = vgui.Create( "DButton", frame ) 
team_1:SetPos( 30, 30 )
team_1:SetSize( 100, 50 ) 
team_1:SetText( "Guards" ) 
team_1.DoClick = function()
	RunConsoleCommand( "team_1" ) 
	frame:Close()
end 

team_2 = vgui.Create( "DButton", frame ) 
team_2:SetPos( 30, 85 )
team_2:SetSize( 100, 50 ) 
team_2:SetText( "Prisoners" ) 
team_2.DoClick = function()
	RunConsoleCommand( "team_2" ) 
	frame:Close()
end 

end
concommand.Add( “team_menu”, set_team )
[/lua]

snip

You haven’t hook the usermessage clientside.

The serverside f2 thing doesn’t bring up the menu, and im not sure whats wrong… i put it in init.lua

instead of


concommand.Add( "team_menu", set_team )

put:


usermessage.Hook( "team_menu", set_team)

then put in init.lua :


function MyMenu( ply ) 
    umsg.Start( "team_menu", ply ) 
    umsg.End()
end 
hook.Add("ShowTeam", "team_menu", MyMenu)

that should work :slight_smile:

P.S.
The reason the other one didn’t work is because you can NOT use a Console Command as a Hook, that is all…

P.S.S. Another thing, go to the lua wiki it has a tutorial on this :), lol updated post like 9 times…

Thanks! :slight_smile: