[DarkRP] Weird Random Hud Error? Please Help Me To Fix This
2 replies, posted
I am really confused on what is going on here, please help me out! Thanks guys!
This error is being caused by my HUD and was working just fine a bit ago and after a server restart it errors out. Also you can see the sandbox hud in the background In-Game.
[QUOTE]
[ERROR] gamemodes/darkrp/gamemode/client/hud.lua:173: attempt to call method 'getDarkRPVar' (a nil value)
1. DrawInfo - gamemodes/darkrp/gamemode/client/hud.lua:173
2. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:311
3. unknown - gamemodes/darkrp/gamemode/client/hud.lua:658
[/QUOTE]
[QUOTE]--[[---------------------------------------------------------
Name: Darkrp HUD by Hillzy
Desc: Draws the gamemods HUD.
-----------------------------------------------------------]]
--[[
Customization
To customize this HUD all you need to do is open hud.lua and look to the top of the file. You will see a bunch of variables, each with is own colour value.
E.g.
local ServerTag = Color(0,0,0).
The three 0's represent the RGB colour values, R being red, G being green and B being blue.
To pick my colours I like to use this tool: [url]http://www.rgbtool.com/[/url]
Simply select a colour then look the right of colour picker and you will see the RGB, you only need the first column.
Place those numbers into "Color(0,0,0) "
E.g.
local ServerTag = Color(255,0,0)
This would give you red.
DO NOT CHANGE THE BLACK TEXT THE "LOCAL VARIABLE" only change the variables after the = sign.
]]--
local Healthbar = Color(255,100,0) //Color of the Health Rectangles/text
local Armorbar = Color(0,100,255) //Color of the Armor Rectangles/text
local RPNameColor = Color(0,0,0) //Color of the players RP Name 0,0,0 is Black
local currency = "Money: $" //Change this to the Currency you want to use
local MoneyColor = Color(0,0,0) //Change this to change the color of the money text
local JobColor = Color(0,0,0) //Change this to change the color of the job text
local SalaryColor = Color(0,0,0) //Change this to change the color of the Salary text
local ServerTagColor = Color(0,0,0) //Change this to change the color of the Server Tag
local ServerTag1 = "GamingPlusCraft DarkRP" //Change this to you servers tag
--[[---------------------------------------------------------
Creating the fonts
-----------------------------------------------------------]]
surface.CreateFont("smallest",
{
font = "Trebuchet MS",
size = 18,
weight = 200
}
)
surface.CreateFont("medium",
{
font = "Trebuchet MS",
size = 22,
weight = 1000
}
)
surface.CreateFont("medium2",
{
font = "Trebuchet MS",
size = 19,
weight = 1000
}
)
surface.CreateFont("large",
{
font = "Trebuchet MS",
size = 26,
weight = 600
}
)
/*---------------------------------------------------------------------------
HUD ConVars
---------------------------------------------------------------------------*/
local ConVars = {}
local HUDWidth
local HUDHeight
local Color = Color
local cvars = cvars
local draw = draw
local GetConVar = GetConVar
local Lerp = Lerp
local localplayer
local pairs = pairs
local SortedPairs = SortedPairs
local string = string
local surface = surface
local table = table
local tostring = tostring
local basetex = Material("darkrphud.png","nocull")
CreateClientConVar("weaponhud", 0, true, false)
local function ReloadConVars()
ConVars = {
background = {0,0,0,100},
Healthbackground = {0,0,0,200},
Healthforeground = {140,0,0,180},
HealthText = {255,255,255,200},
Job1 = {0,0,150,200},
Job2 = {0,0,0,255},
salary1 = {255,208,0,200},
salary2 = {255,208,0,200}
}
for name, Colour in pairs(ConVars) do
ConVars[name] = {}
for num, rgb in SortedPairs(Colour) do
local CVar = GetConVar(name..num) or CreateClientConVar(name..num, rgb, true, false)
table.insert(ConVars[name], CVar:GetInt())
if not cvars.GetConVarCallbacks(name..num, false) then
cvars.AddChangeCallback(name..num, function() timer.Simple(0,ReloadConVars) end)
end
end
ConVars[name] = Color(unpack(ConVars[name]))
end
HUDWidth = (GetConVar("HudW") or CreateClientConVar("HudW", 240, true, false)):GetInt()
HUDHeight = (GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()
if not cvars.GetConVarCallbacks("HudW", false) and not cvars.GetConVarCallbacks("HudH", false) then
cvars.AddChangeCallback("HudW", function() timer.Simple(0,ReloadConVars) end)
cvars.AddChangeCallback("HudH", function() timer.Simple(0,ReloadConVars) end)
end
end
ReloadConVars()
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 Scrw, Scrh, RelativeX, RelativeY
/*---------------------------------------------------------------------------
HUD Seperate Elements
---------------------------------------------------------------------------*/
local Health = 0
local function DrawHealth()
--[HEALTH]--
local client = LocalPlayer();
local hp = client:Health();
local hpr = math.Round(hp/6.3);
local howManyLoops = hpr
for i=1,howManyLoops do
surface.SetDrawColor(Healthbar);
surface.DrawTexturedRectRotated(1 + (i*18), ScrH() - 18, 7, 18,45);
end
draw.SimpleText(hp.."%","medium",318, ScrH()-29, Color(0,0,0))
draw.SimpleText(hp.."%","medium",318, ScrH()-30, Color(255,100,0))
if hp <= 35 then
draw.SimpleText("LOW HEALTH WARNING!","smallest",131, ScrH()-25, Color(0,0,0))
draw.SimpleText("LOW HEALTH WARNING!","smallest",130, ScrH()-26, Color(255,100,0))
end
end
local function DrawInfo()
local Salary = GAMEMODE.Config.currency .. (localplayer:getDarkRPVar("salary") or 0)
local Wallet = GAMEMODE.Config.currency, (formatNumber(localplayer:getDarkRPVar("money") or 0) or 0)
local JobWallet = {
(localplayer:getDarkRPVar("job") or "")
}
JobWallet = table.concat(JobWallet)
local wep = localplayer:GetActiveWeapon()
if IsValid(wep) and GAMEMODE.Config.weaponhud then
local name = wep:GetPrintName();
draw.DrawText("Weapon: "..name, "UiBold", RelativeX + 5, RelativeY - HUDHeight - 30, Color(255, 255, 255, 255), 0)
end
draw.SimpleText("Salary: "..Salary, "medium", ScrW() - 500,2.5, SalaryColor)
surface.SetFont("UiBold")
local w, h = surface.GetTextSize(Salary)
draw.SimpleText("Job: "..JobWallet, "medium", ScrW() - 300, 2.5, JobColor)
draw.SimpleText(currency..formatNumber(localplayer:getDarkRPVar("money") or 0) or 0, "medium", 300, 2.5, MoneyColor)
end
local Page = Material("icon16/page_white_text.png")
local function GunLicense()
if localplayer:getDarkRPVar("HasGunlicense") then
surface.SetMaterial(Page)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(RelativeX + HUDWidth, 10, 32, 32)
end
end
local function Agenda()
local DrawAgenda, AgendaManager = DarkRPAgendas[localplayer:Team()], localplayer:Team()
if not DrawAgenda then
for k,v in pairs(DarkRPAgendas) do
if table.HasValue(v.Listeners or {}, localplayer:Team()) then
DrawAgenda, AgendaManager = DarkRPAgendas[k], k
break
end
end
end
if DrawAgenda then
draw.RoundedBox(10, 10, 35, 460, 110, Color(0, 0, 0, 155))
draw.RoundedBox(10, 12, 35, 456, 106, Color(51, 58, 51,100))
draw.RoundedBox(10, 12, 35, 456, 20, Color(0, 0, 70, 100))
draw.DrawText(DrawAgenda.Title, "DarkRPHUD1", 30, 35, Color(255,0,0,255),0)
local AgendaText = {}
for k,v in pairs(team.GetPlayers(AgendaManager)) do
if not v.DarkRPVars then continue end
table.insert(AgendaText, v:getDarkRPVar("agenda"))
end
local text = table.concat(AgendaText, "\n")
text = text:gsub("//", "\n"):gsub("\\n", "\n")
text = GAMEMODE:TextWrap(text, "DarkRPHUD1", 440)
draw.DrawText(text, "DarkRPHUD1", 30, 55, Color(255,255,255,255),0)
end
end
local VoiceChatTexture = surface.GetTextureID("voice/i
Update your DarkRP.
Do I actually need to totally re-install DarkRP?
Please don't get upset about this but I know how to install the gamemode and edit it and what not just not sure the exact way to re-install. Do I just copy (Replace) the dark-rp files?
[QUOTE=Bo98;42109335]Update your DarkRP.[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.