So, I've been having some trouble lately with panels and in common; DLabels.
I think it's due to the way the panel is being requested, but my DLabel doesn't work whenever I click on it. No error, it just sits there and does nothing.
Here is my code:
f1menu.lua
surface.CreateFont( "frame", {
size = 40,
weight = 100,
antialias = true,
shadow = false,
font = "Segoe UI"
})
local PANEL = {
Init = function(GLHelp)
GLHelp:SetSize(900, 500)
GLHelp:Center()
GLHelp:SetVisible(true)
local x, y = GLHelp:GetSize()
local close = vgui.Create( "DLabel", GLHelp )
close:SetText("X")
close:SetFont("frame")
close:SetSize(65,65)
close:SetPos(x-50, 0)
close.Paint = function(w, h)
close:SetColor( Color(255, 255, 255) )
end
close.DoClick = function()
GLHelp:SetVisible( false )
end
end,
Paint = function(self, w, h)
-- Blabla
end
}
vgui.Register("glhelp", PANEL)
cl_init.lua
AddCSLuaFile("f1menu.lua")
net.Receive("f1menu", function()
if( !glhelp ) then
glhelp = vgui.Create("glhelp")
glhelp:SetVisible(false)
end
if (glhelp:IsVisible()) then
glhelp:SetVisible(false)
gui.EnableScreenClicker(false)
else
glhelp:SetVisible(true)
gui.EnableScreenClicker(true)
end
end)
Init.lua
AddCSLuaFile("f1menu.lua")
util.AddNetworkString("f1menu")
function GM:ShowHelp(ply)
net.Start("f1menu")
net.Send(ply)
end
How do I make it work? Thanks alot already!
Solved.
Sorry, you need to Log In to post a reply to this thread.