I'm making a server portal derma but I'm having problems with buttons
6 replies, posted
I have these problems:
1) Whenever I click the close button for the derma the button stays on screen until reload.
2) When my derma panel animation starts to move to middle of screen the button is already instantly there.
My Code:
https://pastebin.com/TtczdP0g
hook.Add( "OnPlayerChat", "serverlist", function(ply, text, TeamOnly, PlayerIsDead)
if (string.lower( text ) == "!servers" ) then
local ServerPanel = vgui.Create( "DFrame" )
ServerPanel:SetPos(-300, 300 )
ServerPanel:MoveTo(ScrW()/2.4, ScrH()/2-250, 3, 0, 4)
ServerPanel:SetSize( 290, 512 )
ServerPanel:SetTitle( "Full-Moon Networks Server List" )
ServerPanel:MakePopup()
ServerPanel:SetDraggable( false )
timer.Simple(3, function()
local ServerButton1 = vgui.Create( "DButton", ServerPanel )
ServerButton1:SetText( "Connect to Jedi Vs Sith" )
ServerButton1:SetPos( ScrW()/2.4, ScrH()/2-250 )
ServerButton1:SetSize( 250, 30 )
ServerButton1.DoClick = function()
LocalPlayer():ConCommand( "connect " .. portals.button01IP )
ServerPanel:Close()
end
end)
end
end)
Now the button doesn't appear at all.
Use the code:
hook.Add( "OnPlayerChat", "serverlist", function(ply, text, TeamOnly, PlayerIsDead)
if (string.lower( text ) == "!servers" ) then
local ServerPanel = vgui.Create( "DFrame" )
ServerPanel:SetPos(-300, 300 )
ServerPanel:MoveTo(ScrW()/2.4, ScrH()/2-250, 3, 0, 4)
ServerPanel:SetSize( 290, 512 )
ServerPanel:SetTitle( "Full-Moon Networks Server List" )
ServerPanel:MakePopup()
ServerPanel:SetDraggable( false )
local ServerButton1 = vgui.Create( "DButton", ServerPanel )
ServerButton1:SetText( "Connect to Jedi Vs Sith" )
ServerButton1:SetPos( ServerPanel:GetWide() - 270, 30)
ServerButton1:SetSize( 250, 30 )
ServerButton1.DoClick = function()
LocalPlayer():ConCommand( "connect " .. portals.button01IP )
ServerPanel:Close()
end
end
end)
Thanks, that fixed it!
There is a few things wrong here, you're not setting any information for the 2nd button but instead you're putting the information for the 1st one back.
An example (do this with all of them):
ServerButton1:SetText( " " .. portals.button02text )
to
ServerButton2:SetText( " " .. portals.button02text )
Sorry, you need to Log In to post a reply to this thread.