• Help with this HUD
    5 replies, posted
Hello, my name is Louis and when I purchased this server the HUD worked great, but for some reason after adding 2 addons the HUD just broke giving me an error about starting health being a 'nil' value. So I assumed the HUD was garbage and got a new one, which ended up giving me this error: [ERROR] gamemodes/darkrp/gamemode/libraries/fn.lua:279: bad argument #1 to 'ipairs' (table expected, got nil) 1. ipairs - [C]:-1 2. Foldl - gamemodes/darkrp/gamemode/libraries/fn.lua:279 3. unknown - gamemodes/darkrp/entities/entities/darkrp_laws/cl_init.lua:71 Does anybody else have this problem? or at least with that "starting health a 'nil' value" error? really annoying and I would love to continue my developement with a working HUD and F4 menu, thanks. (extra info: it's a DarkRP server)
Code?
[B][U]This is the DarkRP modification HUD file (the one im trying to get to work):[/U][/B] /*--------------------------------------------------------------------------- Made By: TheCodingBeast This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit [url]http://creativecommons.org/licenses/by-nc-sa/4.0/[/url]. ---------------------------------------------------------------------------*/ local hideHUDElements = { ["DarkRP_HUD"] = true, ["DarkRP_EntityDisplay"] = false, ["DarkRP_ZombieInfo"] = false, ["DarkRP_LocalPlayerHUD"] = true, ["DarkRP_Agenda"] = false, ["DarkRP_Hungermod"] = true, } hook.Add("HUDShouldDraw", "HideDefaultDarkRPHud", function(name) if hideHUDElements[name] or name == "CHudHealth" or name == "CHudBattery" or name == "CHudSuitPower" then return false end end) /*--------------------------------------------------------------------------- Hud Settings ---------------------------------------------------------------------------*/ local HUD = {} HUD.Width = 400 HUD.Height = 125 HUD.X = "left" -- left / center / right HUD.Y = "bottom"; -- bottom / center / top HUD.HealthColor = Color(255, 0, 0, 150) HUD.ArmorColor = Color(0, 150, 255, 150) HUD.ShowLicenseWanted = true -- true / false -- Language HUD.Wallet = "Wallet" HUD.Salary = "Salary" HUD.Health = "Health" HUD.Armor = "Armor" HUD.License1= "No License" HUD.License2= "License" HUD.Wanted1 = "Not Wanted" HUD.Wanted2 = "Wanted" /*--------------------------------------------------------------------------- Hud Settings Process ---------------------------------------------------------------------------*/ local Border = 15 if HUD.X == "left" then HUD.PosX = Border elseif HUD.X == "center" then HUD.PosX = ScrW() / 2 - HUD.Width / 2 elseif HUD.X == "right" then HUD.PosX = ScrW() - Border else HUD.PosX = Border end if HUD.Y == "bottom" then HUD.PosY = ScrH() - HUD.Height - Border elseif HUD.Y == "center" then HUD.PosY = ScrH() / 2 - HUD.Height / 2 elseif HUD.Y == "top" then if HUD.ShowLicenseWanted == true then HUD.PosY = Border + 24 else HUD.PosY = Border end else HUD.PosY = ScrH() - Border end /*--------------------------------------------------------------------------- Base ---------------------------------------------------------------------------*/ local function formatNumber(n) if not n then return "" end if n >= 1e14 then return tostring(n) end n = tostring(n) local sep = sep or "," local dp = string.find(n, "%.") or #n+1 for i=dp-4, 1, -3 do n = n:sub(1, i) .. sep .. n:sub(i+1) end return n end local function HudBase() draw.RoundedBox(6, HUD.PosX, HUD.PosY, HUD.Width, HUD.Height, Color(0, 0, 0, 200)) surface.SetFont("TCBFont") end local function HudArmor() draw.RoundedBox(6, HUD.PosX+5, HUD.PosY+HUD.Height-24-5, HUD.Width-10, 24, Color(0, 0, 0, 200)) local Armor = LocalPlayer():Armor() or 0 local FullArmor = LocalPlayer():Armor() or 0 if Armor < 0 then Armor = 0 elseif Armor > 100 then Armor = 100 end if Armor != 0 then draw.RoundedBox(6, HUD.PosX+5+2, HUD.PosY+HUD.Height-24-5+2, (HUD.Width-10-4) * Armor / 100, 24-4, HUD.ArmorColor) end draw.DrawText(HUD.Armor..": "..FullArmor, "TCBFont", HUD.PosX+HUD.Width/2+1, HUD.PosY+HUD.Height-24-5+3+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(HUD.Armor..": "..FullArmor, "TCBFont", HUD.PosX+HUD.Width/2, HUD.PosY+HUD.Height-24-5+3, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function HudHealth() draw.RoundedBox(6, HUD.PosX+5, HUD.PosY+HUD.Height-48-10, HUD.Width-10, 24, Color(0, 0, 0, 200)) local Health = LocalPlayer():Health() or 0 local FullHealth = LocalPlayer():Health() or 0 if Health < 0 then Health = 0 elseif Health > 100 then Health = 100 end local DrawHealth = math.Min(Health/GAMEMODE.Config.startinghealth, 1) if Health != 0 then draw.RoundedBox(6, HUD.PosX+5+2, HUD.PosY+HUD.Height-48-10+2, (HUD.Width-10-4) * DrawHealth, 24-4, HUD.HealthColor) end draw.DrawText(HUD.Health..": "..FullHealth, "TCBFont", HUD.PosX+HUD.Width/2+1, HUD.PosY+HUD.Height-48-10+3+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(HUD.Health..": "..FullHealth, "TCBFont", HUD.PosX+HUD.Width/2, HUD.PosY+HUD.Height-48-10+3, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function HudName() draw.RoundedBox(6, HUD.PosX+5, HUD.PosY+HUD.Height-72-15, HUD.Width/2-10, 24, Color(0, 0, 0, 200)) local DrawName = LocalPlayer():Nick() or "" local namew,nameh = surface.GetTextSize(DrawName) while namew > (HUD.Width/2-10) do DrawName = string.sub(DrawName, 1, DrawName:len()-6).."..." namew,nameh = surface.GetTextSize(DrawName) end draw.DrawText(DrawName, "TCBFont", HUD.PosX+5+HUD.Width/4-7.5+1, HUD.PosY+HUD.Height-72-15+3+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(DrawName, "TCBFont", HUD.PosX+5+HUD.Width/4-7.5, HUD.PosY+HUD.Height-72-15+3, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function HudJob() draw.RoundedBox(6, HUD.PosX+5+HUD.Width/2, HUD.PosY+HUD.Height-72-15 , HUD.Width/2-10, 24, Color(0, 0, 0, 200)) local DrawJob = LocalPlayer():getDarkRPVar("job") or "" local jobw,jobh = surface.GetTextSize(DrawJob) while jobw > (HUD.Width/2-10) do DrawJob = string.sub(DrawJob, 1, DrawJob:len()-6).."..." jobw,jobh = surface.GetTextSize(DrawJob) end draw.DrawText(DrawJob, "TCBFont", HUD.PosX+5+HUD.Width/2+HUD.Width/4-7.5+1, HUD.PosY+HUD.Height-72-15+3+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(DrawJob, "TCBFont", HUD.PosX+5+HUD.Width/2+HUD.Width/4-7.5, HUD.PosY+HUD.Height-72-15+3, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function HudMoney() draw.RoundedBox(6, HUD.PosX+5, HUD.PosY+HUD.Height-96-20 , HUD.Width/2-10, 24, Color(0, 0, 0, 200)) local DrawMoney = HUD.Wallet..": $"..formatNumber(LocalPlayer():getDarkRPVar("money") or 0) local moneyw,moneyh = surface.GetTextSize(DrawMoney) while moneyw > (HUD.Width/2-10) do DrawMoney = string.sub(DrawMoney, 1, DrawMoney:len()-6).."..." moneyw,moneyh = surface.GetTextSize(DrawMoney) end draw.DrawText(DrawMoney, "TCBFont", HUD.PosX+5+HUD.Width/4-7.5+1, HUD.PosY+HUD.Height-96-15-2+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(DrawMoney, "TCBFont", HUD.PosX+5+HUD.Width/4-7.5, HUD.PosY+HUD.Height-96-15-2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function HudSalary() draw.RoundedBox(6, HUD.PosX+5+HUD.Width/2, HUD.PosY+HUD.Height-96-20 , HUD.Width/2-10, 24, Color(0, 0, 0, 200)) local DrawSalary = HUD.Salary..": $"..formatNumber(LocalPlayer():getDarkRPVar("salary") or 0) local salaryw,salaryh = surface.GetTextSize(DrawSalary) while salaryw > (HUD.Width/2-10) do DrawSalary = string.sub(DrawSalary, 1, DrawSalary:len()-6).."..." salaryw,salaryh = surface.GetTextSize(DrawSalary) end draw.DrawText(DrawSalary, "TCBFont", HUD.PosX+5+HUD.Width/2+HUD.Width/4-7.5+1, HUD.PosY+HUD.Height-96-15-2+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(DrawSalary, "TCBFont", HUD.PosX+5+HUD.Width/2+HUD.Width/4-7.5, HUD.PosY+HUD.Height-96-15-2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function HudLicense() draw.RoundedBoxEx(6, HUD.PosX+HUD.Width/4-50, HUD.PosY-24, 100, 24, Color(0, 0, 0, 200), true, true, false, false) if LocalPlayer():getDarkRPVar("HasGunlicense") then draw.DrawText(HUD.License2, "TCBFont", HUD.PosX+HUD.Width/4+1, HUD.PosY-24+4+1, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) draw.DrawText(HUD.License2, "TCBFont", HUD.PosX+HUD.Width/4, HUD.PosY-24+4, Color(0, 255, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) else draw.DrawText(HUD.License1, "TCBFont", HUD.PosX+HU
Might wanna put that in a code format. ( A lot of scrolling )
lol ya put a code format it looks like # and you high light the code and doe #
Jesus christs put dem brackets on >_>
Sorry, you need to Log In to post a reply to this thread.