So here is my GUI I have been working on. I can't seem to figure out how to remove it from your screen once its ran =X. Also the function buttons() isn't inside of teamselect() because it paints way too many buttons and returns "Too many Pop-ups" in console. Any help on this would be very much appreciated!
[lua]
local foreground = Color(255, 255, 255, 255)
local textColor = Color(255, 255, 255, 255)
local textHoverColor = Color(184, 184, 184, 255)
local background = Color(122,122,122,255)
local modelbg = Color(0, 0, 0, 225)
local btnWidth = 140
local btnHeight = 45
local btnFont = "Trebuchet24"
local yPos = ScrH() / 2 -260
local xPos = ScrW() / 2 -475
local centerY = ScrH() / 2
local centerX = ScrW() / 2
function Button:Hide()
Frame:SetVisible(false)
end
function createButton( width, height, xPosition, yPosition, text, textFont, textColor, textHoverColor, foregroundColor, backgroundColor, playermodel, clickConsoleCommand)
local centerY = ScrH() / 2.0
surface.SetDrawColor( 0, 0, 0, 225 );
surface.DrawRect( 0, 0, ScrW(), centerY - 400 );
surface.DrawRect( 0, centerY + 400, ScrW(), ScrH() - ( centerY+ 400 ) );
local Frame = vgui.Create( "DFrame" )
Frame:SetSize( width, height )
Frame:SetPos( xPosition, yPosition )
Frame:SetTitle( text..": Button" )
Frame:SetVisible(true)
Frame:MakePopup()
local Button = vgui.Create( "DButton" )
Button:SetParent( Frame )
Button:SetSize( width, height)
Button:Center()
Button:SetColor( textColor )
Button:SetFont( textFont )
Button:SetText( text )
local modelButton = vgui.Create( "DModelPanel" )
modelButton:SetModel( playermodel )
modelButton:SetSize( 2400, 700)
modelButton:Center()
modelButton:SetPos (centerX -700, centerY -250)
modelButton:SetCamPos( Vector( 180, 180, 180 ) )
modelButton:SetLookAt( Vector( 0, 0, 0 ) )
modelButton:SetVisible(false)
function Button:OnCursorEntered()
Button:SetColor( textHoverColor )
surface.PlaySound( "/UI/buttonrollover.wav" )
modelButton:SetVisible(true)
end
function Button:OnCursorExited()
Button:SetColor( textColor )
modelButton:SetVisible(false)
end
function Button:OnMousePress()
surface.PlaySound( "/UI/buttonclick.wav" )
Button:Hide()
end
Button.DoClick = function ()
RunConsoleCommand( clickConsoleCommand )
surface.PlaySound( "/UI/buttonclickrelease.wav" )
end
Button.Paint = function()
surface.SetDrawColor( backgroundColor )
surface.DrawRect( 0, 0, width, height)
surface.SetDrawColor( foregroundColor )
surface.DrawOutlinedRect( 0, 0, width, height )
surface.DrawOutlinedRect( 1, 1, width-2, height-2 )
surface.DrawOutlinedRect( 2, 2, width-4, height-4 )
end
end
--------------------------------------------------------------------------------TEAM SELECTION---------------------------------------------------------------------------------------------
function teamselect()
--Model Box
surface.SetDrawColor(modelbg);
surface.DrawRect( xPos +150, yPos, 650, 515)
surface.SetDrawColor(foreground)
surface.DrawOutlinedRect( xPos +150,yPos, 650, 515 )
surface.DrawOutlinedRect( xPos +149,yPos -1, 652, 517 )
local centerY = ScrH() / 2.0
surface.SetDrawColor( 0, 0, 0, 225 );
surface.DrawRect( 0, 0, ScrW(), centerY - 400 );
surface.DrawRect( 0, centerY + 400, ScrW(), ScrH() - ( centerY+ 400 ) );
hook.Add("HUDPaint", "teamselect", teamselect)
end
concommand.Add( "teamselection", teamselect)
function buttons()
createButton(btnWidth, btnHeight, xPos, yPos, "HIDERS", btnFont, textColor, textHoverColor,foreground, background,"models/player/gman_high.mdl", "kill" )
createButton(btnWidth, btnHeight, xPos, yPos +55, "SEEKERS", btnFont, textColor, textHoverColor,foreground, background,"models/player/gman_high.mdl", "kill" )
createButton(btnWidth, btnHeight, xPos, yPos +470, "SPECTATE", btnFont, textColor, textHoverColor,foreground, background,"models/player/gman_high.mdl", "kill" )
createButton(btnWidth, btnHeight, xPos +661, yPos +526, "BUILDER", btnFont, textColor, textHoverColor,foreground, background,"models/player/gman_high.mdl", "kill" )
end
concommand.Add( "teambuttons", buttons)
[/lua]
Well this is certainly an interesting way to make a GUI... I would try to close the frame instead of hiding it. Take a gander over at this; [URL]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexc974.html[/URL]
myButton.DoClick = function() myParent:Close() end
tyvm for the help and way to make me feel like shit haha
Sorry, you need to Log In to post a reply to this thread.