[ERROR] gamemodes/darkrp/gamemode/client/hud.lua:276: attempt to call field 'getPhrase' (a nil value)
1. LockDown - gamemodes/darkrp/gamemode/client/hud.lua:276
2. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:332
3. unknown - gamemodes/darkrp/gamemode/client/hud.lua:507
[CODE]basecolour = Color(20,20,20,230)
overlay = Color(0,0,0,0)
overlay2 = Color(20,20,20,0)
--[[---------------------------------------------------------
Creating the fonts
-----------------------------------------------------------]]
surface.CreateFont("smallest",
{
font = "Bebas Neue",
size = 18,
weight = 200,
outline = false,
antialias = true
}
)
surface.CreateFont("medium",
{
font = "Bebas Neue",
size = 25,
weight = 400,
outline = false,
antialias = true
}
)
surface.CreateFont("medium2",
{
font = "Bebas Neue",
size = 19,
weight = 1000,
outline = false,
antialias = true
}
)
surface.CreateFont("large",
{
font = "Bebas Neue",
size = 26,
weight = 600,
outline = false,
antialias = true
}
)
surface.CreateFont("large123",
{
font = "Bebas Neue",
size = 23,
weight = 600,
outline = false,
antialias = true
}
)
surface.CreateFont("large1234",
{
font = "Bebas Neue",
size = 23,
weight = 400,
outline = false,
antialias = true
}
)
surface.CreateFont( "DarkRPHUD6",
{
font = "Bebas Neue",
size = 45,
weight = 400,
shadow = false,
italic = false,
antialias = true
}
)
/*---------------------------------------------------------------------------
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,255},
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()
local ply = LocalPlayer()
local hp = ply:Health()
draw.RoundedBox(0, 15, ScrH() - 28, math.Clamp(hp, 0, 240)*2.4, 18, Color(200,0,100,0))
draw.RoundedBox(0, 15, ScrH() - 28, math.Clamp(hp, 0, 240)*2.4, 10, Color(217,0,119,0))
end
local function DrawArmor()
local ply = LocalPlayer()
local ar = ply:Armor()
draw.RoundedBox(0, 15, ScrH() - 52, math.Clamp(ar, 0, 240)*2.4, 18, Color(1,100,80,0))
draw.RoundedBox(0, 15, ScrH() - 52, math.Clamp(ar, 0, 240)*2.4, 10, Color(2,122,96,0))
end
local function GetAmmo(ply)
local weap = ply:GetActiveWeapon()
if not weap or not ply:Alive() then return -1 end
local ammo_inv = weap:Ammo1() or 0
local ammo_clip = weap:Clip1() or 0
local ammo_max = weap.Primary.ClipSize or 0
return ammo_clip, ammo_max, ammo_inv
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, 180), 0)
end
surface.SetFont("UiBold")
local w, h = surface.GetTextSize(Salary)
draw.SimpleText(""..JobWallet, "medium", ScrW() - 80, ScrH() - 30, Color(255,255,255,180), TEXT_ALIGN_CENTER)
draw.SimpleText(Wallet..formatNumber(localplayer:getDarkRPVar("money") or 0) or 0, "medium", ScrW() - 210, ScrH() - 30, Color(255,255,255,180), TEXT_ALIGN_CENTER)
end
local Page = Material( "icon16/page_white_text.png" )
local function GunLicense()
if LocalPlayer().DarkRPVars.HasGunlicense then
surface.SetMaterial(Page)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRect(RelativeX + HUDWidth, ScrH() - 34, 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, 10, 460, 110, Color(0, 0, 0, 0))
draw.RoundedBox(0, 12, 12, 456, 100, Color(0, 0, 0,120))
draw.RoundedBox(0, 11, 11, 458, 102, Color(255, 255, 255,50))
draw.RoundedBox(0, 12, 12, 456, 20, Color(0, 0, 0, 120))
draw.DrawText(DrawAgenda.Title, "Da
Gee, glad you narrowed it down for us. Why not just copy the line of code that is giving the error and paste that? That way we do not have to search through all that code.
Stop editing core files.
please change the health / armor bits from if / elseif < x then...
use math.Round( health, 0 ) to round, with 0 decimals.
I don't know if that was a core decision of whatever you're editing, or your addition; but it's wrong.
[QUOTE=brandonj4;43174841]Stop editing core files.[/QUOTE]
I forgot to say it's DarkRP 2.4.3
[QUOTE=Fortune11709;43174832]Gee, glad you narrowed it down for us. Why not just copy the line of code that is giving the error and paste that? That way we do not have to search through all that code.[/QUOTE]
Can't you just paste the code in paste and look at the line number? I'm not really a coder so I'm not so familiar with how to do everything.
put your sister on the phone
I just realized all my huds for 2.4.3 are getting a simular getphrase error on my 2.4.3 server. Why?
This makes no sense..
update:
if i change the line to this should it work?
local function LockDown()
local chbxX, chboxY = chat.GetChatBoxPos()
if util.tobool(GetConVarNumber("DarkRP_LockDown")) then
local cin = (math.sin(CurTime()) + 1) / 2
local chatBoxSize = math.floor(ScrH() / 4)
draw.DrawText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_LEFT)
end
end
[QUOTE=Gomez;43183641]I forgot to say it's DarkRP 2.4.3
Can't you just paste the code in paste and look at the line number? I'm not really a coder so I'm not so familiar with how to do everything.[/QUOTE]
Can't you just learn how to program? It's not like you're trying to program without knowing how to program or anything...
DUDE! It gives you the line number the error is on. Copy that line, paste it. Simple.
[lua] --[[Drawing the Text]]--
local health = LocalPlayer():Health()
local healthStatus = "Health: 100"
if (health < 1) then healthStatus = "Health: 0"
elseif (health < 2) then healthStatus = "Health: 1"
elseif (health < 3) then healthStatus = "Health: 2"
elseif (health < 4) then healthStatus = "Health: 3"
elseif (health < 5) then healthStatus = "Health: 4"
elseif (health < 6) then healthStatus = "Health: 5"
elseif (health < 7) then healthStatus = "Health: 6"
elseif (health < 8) then healthStatus = "Health: 7"
elseif (health < 9) then healthStatus = "Health: 8"
elseif (health < 10) then healthStatus = "Health: 9"
elseif (health < 11) then healthStatus = "Health: 10"
elseif (health < 12) then healthStatus = "Health: 11"
elseif (health < 13) then healthStatus = "Health: 12"
elseif (health < 14) then healthStatus = "Health: 13"
elseif (health < 15) then healthStatus = "Health: 14"
elseif (health < 16) then healthStatus = "Health: 15"
elseif (health < 17) then healthStatus = "Health: 16"
elseif (health < 18) then healthStatus = "Health: 17"
elseif (health < 19) then healthStatus = "Health: 18"
elseif (health < 20) then healthStatus = "Health: 19"
elseif (health < 21) then healthStatus = "Health: 20"
elseif (health < 22) then healthStatus = "Health: 21"
elseif (health < 23) then healthStatus = "Health: 22"
elseif (health < 24) then healthStatus = "Health: 23"
elseif (health < 25) then healthStatus = "Health: 24"
elseif (health < 26) then healthStatus = "Health: 25"
elseif (health < 27) then healthStatus = "Health: 26"
elseif (health < 28) then healthStatus = "Health: 27"
elseif (health < 29) then healthStatus = "Health: 28"
elseif (health < 30) then healthStatus = "Health: 29"
elseif (health < 31) then healthStatus = "Health: 30"
elseif (health < 32) then healthStatus = "Health: 31"
elseif (health < 33) then healthStatus = "Health: 32"
elseif (health < 34) then healthStatus = "Health: 33"
elseif (health < 35) then healthStatus = "Health: 34"
elseif (health < 36) then healthStatus = "Health: 35"
elseif (health < 37) then healthStatus = "Health: 36"
elseif (health < 38) then healthStatus = "Health: 37"
elseif (health < 39) then healthStatus = "Health: 38"
elseif (health < 40) then healthStatus = "Health: 39"
elseif (health < 41) then healthStatus = "Health: 40"
elseif (health < 42) then healthStatus = "Health: 41"
elseif (health < 43) then healthStatus = "Health: 42"
elseif (health < 44) then healthStatus = "Health: 43"
elseif (health < 45) then healthStatus = "Health: 44"
elseif (health < 46) then healthStatus = "Health: 45"
elseif (health < 47) then healthStatus = "Health: 46"
elseif (health < 48) then healthStatus = "Health: 47"
elseif (health < 49) then healthStatus = "Health: 48"
elseif (health < 50) then healthStatus = "Health: 49"
elseif (health < 51) then healthStatus = "Health: 50"
elseif (health < 52) then healthStatus = "Health: 51"
elseif (health < 53) then healthStatus = "Health: 52"
elseif (health < 54) then healthStatus = "Health: 53"
elseif (health < 55) then healthStatus = "Health: 54"
elseif (health < 56) then healthStatus = "Health: 55"
elseif (health < 57) then healthStatus = "Health: 56"
elseif (health < 58) then healthStatus = "Health: 57"
elseif (health < 59) then healthStatus = "Health: 58"
elseif (health < 60) then healthStatus = "Health: 59"
elseif (health < 61) then healthStatus = "Health: 60"
elseif (health < 62) then healthStatus = "Health: 61"
elseif (health < 63) then healthStatus = "Health: 62"
elseif (health < 64) then healthStatus = "Health: 63"
elseif (health < 65) then healthStatus = "Health: 64"
elseif (health < 66) then healthStatus = "Health: 65"
elseif (health < 67) then healthStatus = "Health: 66"
elseif (health < 68) then healthStatus = "Health: 67"
elseif (health < 69) then healthStatus = "Health: 68"
elseif (health < 70) then healthStatus = "Health: 69"
elseif (health < 71) then healthStatus = "Health: 70"
elseif (health < 72) then healthStatus = "Health: 71"
elseif (health < 73) then healthStatus = "Health: 72"
elseif (health < 74) then healthStatus = "Health: 73"
elseif (health < 75) then healthStatus = "Health: 74"
elseif (health < 76) then healthStatus = "Health: 75"
elseif (health < 77) then healthStatus = "Health: 76"
elseif (health < 78) then healthStatus = "Health: 77"
elseif (health < 79) then healthStatus = "Health: 78"
elseif (health < 80) then healthStatus = "Health: 79"
elseif (health < 81) then healthStatus = "Health: 80"
elseif (health < 82) then healthStatus = "Health: 81"
elseif (health < 83) then healthStatus = "Health: 82"
elseif (health < 84) then healthStatus = "Health: 83"
elseif (health < 85) then healthStatus = "Health: 84"
elseif (health < 86) then healthStatus = "Health: 85"
elseif (health < 87) then healthStatus = "Health: 86"
elseif (health < 88) then healthStatus = "Health: 87"
elseif (health < 89) then healthStatus = "Health: 88"
elseif (health < 90) then healthStatus = "Health: 89"
elseif (health < 91) then healthStatus = "Health: 90"
elseif (health < 92) then healthStatus = "Health: 91"
elseif (health < 93) then healthStatus = "Health: 92"
elseif (health < 94) then healthStatus = "Health: 93"
elseif (health < 95) then healthStatus = "Health: 94"
elseif (health < 96) then healthStatus = "Health: 95"
elseif (health < 97) then healthStatus = "Health: 96"
elseif (health < 98) then healthStatus = "Health: 97"
elseif (health < 99) then healthStatus = "Health: 98"
elseif (health < 100) then healthStatus = "Health: 99"
end
local armorStatus = "Fully Armored"
local armor = LocalPlayer():Armor()
if (armor < 1) then armorStatus = "Armor: 0"
elseif (armor < 2) then armorStatus = "Armor: 1"
elseif (armor < 3) then armorStatus = "Armor: 2"
elseif (armor < 4) then armorStatus = "Armor: 3"
elseif (armor < 5) then armorStatus = "Armor: 4"
elseif (armor < 6) then armorStatus = "Armor: 5"
elseif (armor < 7) then armorStatus = "Armor: 6"
elseif (armor < 8) then armorStatus = "Armor: 7"
elseif (armor < 9) then armorStatus = "Armor: 8"
elseif (armor < 10) then armorStatus = "Armor: 9"
elseif (armor < 11) then armorStatus = "Armor: 10"
elseif (armor < 12) then armorStatus = "Armor: 11"
elseif (armor < 13) then armorStatus = "Armor: 12"
elseif (armor < 14) then armorStatus = "Armor: 13"
elseif (armor < 15) then armorStatus = "Armor: 14"
elseif (armor < 16) then armorStatus = "Armor: 15"
elseif (armor < 17) then armorStatus = "Armor: 16"
elseif (armor < 18) then armorStatus = "Armor: 17"
elseif (armor < 19) then armorStatus = "Armor: 18"
elseif (armor < 20) then armorStatus = "Armor: 19"
elseif (armor < 21) then armorStatus = "Armor: 20"
elseif (armor < 22) then armorStatus = "Armor: 21"
elseif (armor < 23) then armorStatus = "Armor: 22"
elseif (armor < 24) then armorStatus = "Armor: 23"
elseif (armor < 25) then armorStatus = "Armor: 24"
elseif (armor < 26) then armorStatus = "Armor: 25"
elseif (armor < 27) then armorStatus = "Armor: 26"
elseif (armor < 28) then armorStatus = "Armor: 27"
elseif (armor < 29) then armorStatus = "Armor: 28"
elseif (armor < 30) then armorStatus = "Armor: 29"
elseif (armor < 31) then armorStatus = "Armor: 30"
elseif (armor < 32) then armorStatus = "Armor: 31"
elseif (armor < 33) then armorStatus = "Armor: 32"
elseif (armor < 34) then armorStatus = "Armor: 33"
elseif (armor < 35) then armorStatus = "Armor: 34"
elseif (armor < 36) then armorStatus = "Armor: 35"
elseif (armor < 37) then armorStatus = "Armor: 36"
elseif (armor < 38) then armorStatus = "Armor: 37"
elseif (armor < 39) then armorStatus = "Armor: 38"
elseif (armor <
[QUOTE=Bloodwave;43197671] LMFAO. [/QUOTE]
dude did you write that, because if you did. you are the biggest retard in existence
Oh my gosh this code is cancerous.
Holy Fuck. Who fuck copy/pasted this from a cancerous YouTube guide that a 3 year old kid made
200 lines of code for what you could have done in 1. Lol.
[QUOTE=Gomez;43196196]I just realized all my huds for 2.4.3 are getting a simular getphrase error on my 2.4.3 server. Why?
This makes no sense..
update:
if i change the line to this should it work?
local function LockDown()
local chbxX, chboxY = chat.GetChatBoxPos()
if util.tobool(GetConVarNumber("DarkRP_LockDown")) then
local cin = (math.sin(CurTime()) + 1) / 2
local chatBoxSize = math.floor(ScrH() / 4)
draw.DrawText(DarkRP.getPhrase("lockdown_started"), "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_LEFT)
end
end[/QUOTE]
I don't actually think the error has much to do with your own code, could be related to a DarkRP bug.
Try replacing "DarkRP.getPhrase" with "DarkRP:getPhrase". If that doesn't work, then you can replace the whole "DarkRP.getPhrase("lockdown_started")" phrase with your own string like "Lockdown Started."
DarkRP tries to be so object-oriented and clean that sometimes things are over-complicated like this.
Also, you might consider revising your unique solution to updating the armor and HP text.
I do sympathize with your issues though. Most the talented developers aren't too into helping with simple stuff like this. So instead you get a bunch of idiots who think their library of batch file shortcuts makes them professional developers-- and thus make fun of the arbitrary aspects of your code because they lack the intellect to actually solve any problems.
Good luck.
That was the most beautiful if block I've ever seen
Sorry, you need to Log In to post a reply to this thread.