Error at function ContextClose()
And all derma menu not working
attempt to call method 'Close' (a nil value)
I've create derma menu and it worked in garrysmodlua folder,
then I moved flies to addon floder and it stopped working.
cl_init.lua
AddCSLuaFile("pbfhud.lua")
include("pbfhud.lua")
pbfhud.lua
AddCSLuaFile()
local statBarW, statBarH = ScrW() / 400, ScrH() / 10
local barW, barH = ScrW() / 4, ScrH() / 10
local btnW, btnH = ScrW() / 4, ScrH() / 20
surface.CreateFont( "NotDermaDefault", {
font = "Arial",
extended = false,
size = 25,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
local function DrawInventorySlot( )
end
local function DrawBar(x, y, w, h, color, text, val, name)
local rtext = text .. ": " .. val
local tW, tH = surface.GetTextSize(rtext)
tH = tH / 2
if (name == true) then
tW = tW / 7
end
draw.RoundedBox(0, x, y, w, h, color)
draw.SimpleText(rtext, "NotDermaDefault", barW / 2 - tW / 7, barH / 2 - tH + y, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
end
function ContextOpen()
gui.EnableScreenClicker( true )
menu = vgui.Create("DFrame")
menu:SetSize(ScrW(), ScrH() + 100)
menu:ShowCloseButton(false)
menu:SetTitle("")
menu:Center()
menu:SetDraggable(false)
menu:SetBackgroundBlur(true)
menu:SetMouseInputEnabled(true)
menu.Paint = function()
draw.RoundedBox(0, 0, 0, ScrW(), ScrH(), Color(0,0,0,100))
local blur = Material("pp/blurscreen")
local function blurPanel(panel, amount)
local x, y = panel:LocalToScreen(0, 0)
local scrW, scrH = ScrW(), ScrH()
surface.SetDrawColor(255, 255, 255)
surface.SetMaterial(blur)
for i = 1, 6 do
blur:SetFloat("$blur", (i / 3) * (amount or 6))
blur:Recompute()
render.UpdateScreenEffectTexture()
surface.DrawTexturedRect(x * -1, y * -1, scrW, scrH)
end
end
blurPanel(menu, 5)
draw.RoundedBox(0, 0, 0, ScrW() / 4, ScrH(), Color(0,0,0,50))
-- Stats
DrawBar(0, 0, barW, barH, Color(235, 235, 235, 140), "Имя", LocalPlayer():getDarkRPVar("rpname"), true )
DrawBar(0, statBarH, LocalPlayer():Health() * statBarW, barH, Color(255, 50, 43, 140), "Здоровье", LocalPlayer():Health(), false )
DrawBar(0, statBarH * 2, LocalPlayer():Armor() * statBarW, barH, Color(43, 128, 255, 140), "Броня", LocalPlayer():Armor(), false )
DrawBar(0, statBarH * 3, barW, barH, Color(255, 149, 43, 140), "Работа", LocalPlayer():getDarkRPVar("job"), false )
DrawBar(0, statBarH * 4, barW, barH, Color(0, 138, 11, 140), "Зарплата", LocalPlayer():getDarkRPVar("salary"), false )
-- Inventory
draw.RoundedBox(0, barW, 0, ScrW() / 1.7, ScrH(), Color(0,0,0,50))
end
-- Buttons
--fb = vgui.Create("DButton", menu)
--fb:SetSize(btnW, btnH)
--fb:SetPos(0, btnH * 12)
--fb:SetText("")
end
function ContextClose()
menu:Close()
gui.EnableScreenClicker( false )
end
hook.Add ("OnContextMenuOpen", "Context", ContextOpen)
hook.Add ("OnContextMenuClose", "Context", ContextClose)
Files location
..addonspbf_hudluaautorunclientcl_init.lua
..addonspbf_hudluaautorunclientpbfhud.lua
question from:
https://stackoverflow.com/questions/65857905/glua-derma-not-working-attempt-to-call-method-close-a-nil-value