Lua error - HELP

When i’m coming close to a npc in underdone,

Hook ‘DrawNPCInfo’ Failed: [underdone\gamemode\core\clientfiles\menus\cl_hud_npcinfo.lua:17] attempt to index a nil value

and i haven’t changed anything there, must been garry thats done something.

And it only happens on shops, not on etc a questgiver.

The names on them does not show up either, same with the health and level.

Go into underdone\gamemode\core\clientfiles\menus\cl_hud_n pcinfo.lua.

Give us lines 10-20.

local function DrawNPCIcon(entNPC, posNPCPos)
local strIcon = “gui/silkicons/emoticon_smile”
surface.SetDrawColor(255, 255, 255, 255)
surface.SetTexture(surface.GetTextureID(strIcon))
surface.DrawTexturedRect(posNPCPos.x, posNPCPos.y - 25, 16, 16)
end

local function DrawNameText(entNPC, posNPCPos, boolFriendly)
local tblNPCTable = NPCTable(entNPC:GetNWInt(“npc”))
local intLevel = entNPC:GetNWInt(“level”)
local plylevel = math.Clamp(LocalPlayer():GetLevel(),0,999999)
local clrDrawColor = clrWhite
if intLevel < plylevel then clrDrawColor = clrGreen end
if intLevel > plylevel then clrDrawColor = clrRed end
if boolFriendly then clrDrawColor = clrWhite end
local strTitle = tblNPCTable.Title or “”
if tblNPCTable.Shop then strTitle = ShopTable(tblNPCTable.Shop).PrintName end
draw.SimpleTextOutlined(strTitle, “UiBold”, posNPCPos.x, posNPCPos.y - 20, clrDrawColor, 1, 1, 1, clrDrakGray)
local strDrawText = tblNPCTable.PrintName
if !boolFriendly && !entNPC:IsBuilding() then strDrawText = strDrawText … " lv. " … intLevel end
draw.SimpleTextOutlined(strDrawText, “UiBold”, posNPCPos.x, posNPCPos.y - 10, clrDrawColor, 1, 1, 1, clrDrakGray)
if boolFriendly then
surface.SetFont(“UiBold”)
local wide1, high1 = surface.GetTextSize(strTitle)
local wide2, high2 = surface.GetTextSize(strDrawText)
posNPCPos.x = posNPCPos.x + (math.Max(wide1, wide2) / 2) + 5
DrawNPCIcon(entNPC, posNPCPos)
end
end

local function DrawNPCHealthBar(entNPC, posNPCPos)
local clrBarColor = clrGreen
local intHealth = math.Clamp(entNPC:GetNWInt(“Health”),0,999999)
local intMaxHealth = entNPC:GetNWInt(“MaxHealth”)
if intHealth <= (intMaxHealth * 0.2) then clrBarColor = clrRed end
local NpcHealthBar = jdraw.NewProgressBar()
NpcHealthBar:SetDemensions(posNPCPos.x - (80 / 2), posNPCPos.y, 80, 11)
NpcHealthBar:SetStyle(4, clrBarColor)
NpcHealthBar:SetBoarder(1, clrDrakGray)
NpcHealthBar:SetText(“UiBold”, intHealth, clrDrakGray)
NpcHealthBar:SetValue(intHealth, intMaxHealth)
jdraw.DrawProgressBar(NpcHealthBar)
end

local function DrawNPCInfo()
for _, ent in pairs(ents.GetAll()) do
if ValidEntity(ent) && (ent:IsNPC() || ent:IsBuilding()) && ent:GetNWInt(“level”) > 0 then
if ent:GetPos():Distance(LocalPlayer():GetPos()) < 500 then
local tblNPCTable = NPCTable(ent:GetNWInt(“npc”))
if !tblNPCTable then return end
local boolFriendly = tblNPCTable.Race == “human”
local posNPCPos = (ent:GetPos() + Vector(0, 0, 80)):ToScreen()
DrawNameText(ent, posNPCPos, boolFriendly)
if !boolFriendly then DrawNPCHealthBar(ent, posNPCPos) end
end
end
end
end
hook.Add(“HUDPaint”, “DrawNPCInfo”, DrawNPCInfo)

local tblNPCTable = NPCTable(entNPC:GetNWInt(“npc”))

To
local tblNPCTable = {}
tblNPCTable = NPCTable(entNPC:GetNWInt(“npc”))

There are 2 tblnpctable, replace them both with that?

Both, I guess.

Hrm,

Hook ‘DrawNPCInfo’ Failed: [underdone\gamemode\core\clientfiles\menus\cl_hud_npcinfo.lua:51] attempt to index global ‘entNPC’ (a nil value)

now shows up

this is how it is now

local function DrawNPCIcon(entNPC, posNPCPos)
local strIcon = “gui/silkicons/emoticon_smile”
surface.SetDrawColor(255, 255, 255, 255)
surface.SetTexture(surface.GetTextureID(strIcon))
surface.DrawTexturedRect(posNPCPos.x, posNPCPos.y - 25, 16, 16)
end

local function DrawNameText(entNPC, posNPCPos, boolFriendly)
local tblNPCTable = {}
tblNPCTable = NPCTable(entNPC:GetNWInt(“npc”))
local intLevel = entNPC:GetNWInt(“level”)
local plylevel = math.Clamp(LocalPlayer():GetLevel(),0,999999)
local clrDrawColor = clrWhite
if intLevel < plylevel then clrDrawColor = clrGreen end
if intLevel > plylevel then clrDrawColor = clrRed end
if boolFriendly then clrDrawColor = clrWhite end
local strTitle = tblNPCTable.Title or “”
if tblNPCTable.Shop then strTitle = ShopTable(tblNPCTable.Shop).PrintName end
draw.SimpleTextOutlined(strTitle, “UiBold”, posNPCPos.x, posNPCPos.y - 20, clrDrawColor, 1, 1, 1, clrDrakGray)
local strDrawText = tblNPCTable.PrintName
if !boolFriendly && !entNPC:IsBuilding() then strDrawText = strDrawText … " lv. " … intLevel end
draw.SimpleTextOutlined(strDrawText, “UiBold”, posNPCPos.x, posNPCPos.y - 10, clrDrawColor, 1, 1, 1, clrDrakGray)
if boolFriendly then
surface.SetFont(“UiBold”)
local wide1, high1 = surface.GetTextSize(strTitle)
local wide2, high2 = surface.GetTextSize(strDrawText)
posNPCPos.x = posNPCPos.x + (math.Max(wide1, wide2) / 2) + 5
DrawNPCIcon(entNPC, posNPCPos)
end
end

local function DrawNPCHealthBar(entNPC, posNPCPos)
local clrBarColor = clrGreen
local intHealth = math.Clamp(entNPC:GetNWInt(“Health”),0,999999)
local intMaxHealth = entNPC:GetNWInt(“MaxHealth”)
if intHealth <= (intMaxHealth * 0.2) then clrBarColor = clrRed end
local NpcHealthBar = jdraw.NewProgressBar()
NpcHealthBar:SetDemensions(posNPCPos.x - (80 / 2), posNPCPos.y, 80, 11)
NpcHealthBar:SetStyle(4, clrBarColor)
NpcHealthBar:SetBoarder(1, clrDrakGray)
NpcHealthBar:SetText(“UiBold”, intHealth, clrDrakGray)
NpcHealthBar:SetValue(intHealth, intMaxHealth)
jdraw.DrawProgressBar(NpcHealthBar)
end

local function DrawNPCInfo()
for _, ent in pairs(ents.GetAll()) do
if ValidEntity(ent) && (ent:IsNPC() || ent:IsBuilding()) && ent:GetNWInt(“level”) > 0 then
if ent:GetPos():Distance(LocalPlayer():GetPos()) < 500 then
local tblNPCTable = {}
tblNPCTable = NPCTable(entNPC:GetNWInt(“npc”))
if !tblNPCTable then return end
local boolFriendly = tblNPCTable.Race == “human”
local posNPCPos = (ent:GetPos() + Vector(0, 0, 80)):ToScreen()
DrawNameText(ent, posNPCPos, boolFriendly)
if !boolFriendly then DrawNPCHealthBar(ent, posNPCPos) end
end
end
end
end
hook.Add(“HUDPaint”, “DrawNPCInfo”, DrawNPCInfo)

and now…

[underdone\gamemode\core\clientfiles\menus\cl_shopmenu.lua:45] attempt to index local ‘tblShopTable’ (a nil value)

And now… once again

Hook ‘DrawNPCInfo’ Failed: [gamemodes\underdone\gamemode\core\clientfiles\menus\cl_hud_npcinfo.lua:17] attempt to index a nil value

Garry, what have you done?

just tried to copy a old code, still doesn’t work, clearly something to do with garry’s mod

Put your code in [lua ] [/ lua] tags next time. :confused:

Give us the full code for that lua file might help.

That is the full code.

And i do not bother using stuff like that if there is no button for it

LUA Tags are – Helpful, to the helpers

This

Then why should anyone help you? Lazy fuck.

Go away troll, do not post unless you KNOW how to fix this

I know how to fix it, but I really don’t feel like helping any more.