I want to make team_menu open and close when the user presses the key F1. I used the garrysmod.com tutorial.
[lua]include( "shared.lua" )
function set_team()
frame = vgui.Create( "DFrame" )
frame:SetPos( 100, ScrH() / 2 ) //Set the window in the middle of the players screen/game window
frame:SetSize( 200, 210 ) //Set the size
frame:SetTitle( "Change Your Team!" ) //Set title
frame:SetVisible( true )
frame:SetDraggable( true )
frame:ShowCloseButton( true )
frame:MakePopup()
team_1 = vgui.Create( "DButton", frame )
team_1:SetPos( 30, 30 )
team_1:SetSize( 100, 50 )
team_1:SetText( "Inmates" )
team_1.DoClick = function() //Make the player join team 1
RunConsoleCommand( "team_1" )
RunConsoleCommand( "kill" )
end
team_2 = vgui.Create( "DButton", frame )
team_2:SetPos( 30, 85 ) //Place it next to our previous one
team_2:SetSize( 100, 50 )
team_2:SetText( "Police" )
team_2.DoClick = function() //Make the player join team 2
RunConsoleCommand( "team_2" )
RunConsoleCommand( "kill" )
end
end
concommand.Add( "team_menu", set_team ) [/lua]
How can i do this?
[lua]
function ipresdedbtn()
toggledabtn = !toggledabtn
if toggledabtn then
LocalPlayer():ConCommand("set_team")
else
frame:SetVisible(false)
end
end
concommand.Add("rawrbutton" ipresdedbtn)
[/lua]
Where would i add that? Im still new.
make the client run it then they would have to bind F1 to rawrbutton or rename rawrbutton to team_menu or w/e
You could name the function:
[lua]function GM:ShowHelp()[/lua]
[url]http://wiki.garrysmod.com/?title=Gamemode.ShowHelp[/url]
It's called when the client presses their F1 key.