• Hud Error (Including draw)
    2 replies, posted
I don't really know why this is happening. Error: [code][ERROR] lua/includes/modules/draw.lua:147: bad argument #1 to 'len' (string expected, got nil) 1. len - [C]:-1 2. DrawText - lua/includes/modules/draw.lua:147 3. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:254 4. unknown - gamemodes/darkrp/gamemode/client/hud.lua:379 [ERROR] lua/includes/modules/draw.lua:147: bad argument #1 to 'len' (string expected, got nil) 1. len - [C]:-1 2. DrawText - lua/includes/modules/draw.lua:147 3. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:254 4. unknown - gamemodes/darkrp/gamemode/client/hud.lua:379 [ERROR] lua/includes/modules/draw.lua:147: bad argument #1 to 'len' (string expected, got nil) 1. len - [C]:-1 2. DrawText - lua/includes/modules/draw.lua:147 3. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:254 4. unknown - gamemodes/darkrp/gamemode/client/hud.lua:379 [ERROR] lua/includes/modules/draw.lua:147: bad argument #1 to 'len' (string expected, got nil) 1. len - [C]:-1 2. DrawText - lua/includes/modules/draw.lua:147 3. DrawHUD - gamemodes/darkrp/gamemode/client/hud.lua:254 4. unknown - gamemodes/darkrp/gamemode/client/hud.lua:379 [/code] Hud.lua (Steal my hud, I don't care lol) [code]/*--------------------------------------------------------------------------- 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 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 = {0,150,0,200}, salary2 = {0,0,0,255} } 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 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, 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(0, 3, 3, 460, 110, Color(0, 0, 0, 155)) draw.RoundedBox(0, 5, 5, 456, 106, Color(99, 99, 99,100)) draw.RoundedBox(0, 5, 5, 456, 20, Color(255, 255, 255, 100)) draw.DrawText(DrawAgenda.Title, "DarkRPHUD1", 15, 7, Color(255,255,255,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", 20, 30, Color(255,255,255,255),0) end end local VoiceChatTexture = surface.GetTextureID("voice/icntlk_pl") local function DrawVoiceChat() if localplayer.DRPIsTalking then local chbxX, chboxY = chat.GetChatBoxPos() local Rotating = math.sin(CurTime()*3) local backwards = 0 if Rotating < 0 then Rotating = 1-(1+Rotating) backwards = 180 end surface.SetTexture(VoiceChatTexture) surface.SetDrawColor(ConVars.Healthforeground) surface.DrawTexturedRectRotated(ScrW() - 100, chboxY, Rotating*96, 96, backwards) end end 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 local Arrested = function() end usermessage.Hook("GotArrested", function(msg) local StartArrested = CurTime() local ArrestedUntil = msg:ReadFloat() Arrested = function() if CurTime() - StartArrested <= ArrestedUntil and localplayer:getDarkRPVar("Arrested") then draw.DrawText(DarkRP.getPhrase("youre_arrested", math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "DarkRPHUD1", ScrW()/2, ScrH() - ScrH()/12, Color(255,255,255,255), 1) elseif not localplayer:getDarkRPVar("Arrested") then Arrested = function() end end end end) local AdminTell = function() end usermessage.Hook("AdminTell", function(msg) local Message = msg:ReadString() AdminTell = function() draw.RoundedBox(4, 10, 10, ScrW() - 20, 100, Color(0, 0, 0, 200)) draw.DrawText(DarkRP.getPhrase("listen_up"), "GModToolName", ScrW() / 2 + 10, 10, Color(255, 255, 255, 255), 1) draw.DrawText(Message, "ChatFont", ScrW() / 2 + 10, 80, Color(200, 30, 30, 255), 1) end timer.Simple(10, function() AdminTell = function() end end) end) local g_grds, g_wgrd, g_sz function draw.GradientBox(x, y, w, h, al, ...) g_grds = {...} al = math.Clamp(math.floor(al), 0, 1) if(al == 1) then local t = w w, h = h, t end g_wgrd = w / (#g_grds - 1) local n for i = 1, w do for c = 1, #g_grds do n = c if(i <= g_wgrd * c) then break end end g_sz = i - (g_wgrd * (n - 1)) surface.SetDrawColor( Lerp(g_sz/g_wgrd, g_grds[n].r, g_grds[n + 1].r), Lerp(g_sz/g_wgrd, g_grds[n].g, g_grds[n + 1].g), Lerp(g_sz/g_wgrd, g_grds[n].b, g_grds[n + 1].b), Lerp(g_sz/g_wgrd, g_grds[n].a, g_grds[n + 1].a)) if(al == 1) then surface.DrawRect(x, y + i, h, 1) else surface.DrawRect(x + i, y, 1, h) end end end /*--------------------------------------------------------------------------- Drawing the HUD elements such as Health etc. ---------------------------------------------------------------------------*/ local function DrawHUD() localplayer = localplayer and IsValid(localplayer) and localplayer or LocalPlayer() if not IsValid(localplayer) then return end local shouldDraw = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_HUD") if shouldDraw == false then return end Scrw, Scrh = ScrW(), ScrH() RelativeX, RelativeY = 0, Scrh --Backgro
The error points to a draw.DrawText. [lua]draw.DrawText(LocalPlayer().DarkRPVars.job, "DarkRPHUD1", 605, ScrH() - 19, Color(255, 255, 255, 255), 1)[/lua] LocalPlayer().DarkRPVars.job is nil. It's undefined.
Because it has changed to: LocalPlayer():getDarkRPVar("job")
Sorry, you need to Log In to post a reply to this thread.