Hello.
I’m creating a derma for an addon. I was creating it on my laptop and everything works well but when I have passed it to my computer this error comes out:
[ERROR] addons/delivery_agent/lua/deliveryagent_core/dermas/cl_dframe.lua:41: attempt to index global 'ply' (a nil value)
1. DoClick - addons/delivery_agent/lua/deliveryagent_core/dermas/cl_dframe.lua:41
2. unknown - lua/vgui/dlabel.lua:232
Here is the code:
DeliveryAgent.DFrame = function()
local w = ScrW() / 1.1
local h = ScrH() / 1.1
local PrimaryPannel = vgui.Create("DFrame")
PrimaryPannel:SetPos(ScrW() / 2 - w / 2, ScrH() / 2 - h / 2)
PrimaryPannel:SetSize(w, h)
PrimaryPannel:SetTitle("")
PrimaryPannel:SetDraggable(false)
PrimaryPannel:MakePopup()
PrimaryPannel.Paint = function()
draw.RoundedBox(8, 0, 0, w, h, Color(0, 136, 255, 255))
draw.RoundedBox(0, 0, 0, w, h / 35, Color(255, 255, 255, 255))
draw.DrawText("bla bla bla", "body", w / 30, h / 3.4, Color(255, 255, 255, 255))
end
local PrimaryAccept = vgui.Create("DButton")
PrimaryAccept:SetParent(PrimaryPannel)
PrimaryAccept:SetPos(w - w / 1.1, h - h / 5)
PrimaryAccept:SetText(" ")
PrimaryAccept:SetSize(150, 50)
PrimaryAccept.Paint = function()
draw.RoundedBox(12, 0, 0, 150, 50, Color(255, 255, 255, 255))
draw.DrawText("bla bla", "button", 75, 15, Color(96, 96, 96, 255), TEXT_ALIGN_CENTER)
end
PrimaryAccept.DoClick = function()
if ply:Team() == TEAM_CSMAN then --this is the line 41
PrimaryPannel:Close()
local DermaPanel = vgui.Create("DFrame")
DermaPanel:SetPos(ScrW() / 2 - w / 2, ScrH() / 2 - h / 2)
DermaPanel:SetSize(w, h)
DermaPanel:SetTitle(DeliveryAgent.NPCTitle)
DermaPanel:SetDraggable(false)
DermaPanel:MakePopup()
local JobTable = vgui.Create("DListView", DermaPanel)
JobTable:SetPos(w / 20, h / 2 - 90)
JobTable:SetSize(600, 180)
JobTable:AddColumn("Money"):SetFixedWidth(200)
JobTable:AddColumn("More"):SetFixedWidth(200)
JobTable:AddColumn("Out"):SetFixedWidth(200)
else
JobDermaPanel:Close()
local JobDermaPanel = vgui.Create("DFrame")
JobDermaPanel:SetPos(ScrW() / 2 - w / 2, ScrH() / 2 - h / 2)
JobDermaPanel:SetSize(w, h)
JobDermaPanel:SetTitle(DeliveryAgent.NPCTitle)
JobDermaPanel:SetDraggable(false)
JobDermaPanel:MakePopup()
JobDermaPanel.Paint = function()
draw.RoundedBox(8, 0, 0, w, h, Color(0, 136, 255, 255))
draw.RoundedBox(0, 0, 0, w, h - 520, Color(255, 255, 255, 255))
draw.DrawText("bla bla bla", "body", w / 10, h / 3.4, Color(255, 255, 255, 255))
draw.DrawText("bla bla", "body", w / 10, h / 2.19, Color(255, 0, 0, 255))
end
end
end
I don’t know why it does not work on my computer.
Sorry for the English, I’m Spanish