1. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Error with hud

Discussion in 'DarkRP Modding Questions & Help' started by SprinteR, Dec 31, 2017.

  1. SprinteR

    SprinteR New Member

    Error in hook HUDPaint: gamemodes/darkrp/gamemode/modules/hud/cl_hud.lua:22: attempt to call method 'Team' (a nil value)
    stack traceback:
    gamemodes/darkrp/gamemode/modules/hud/cl_hud.lua:22: in function 'DrawHud1'
    gamemodes/darkrp/gamemode/modules/hud/cl_hud.lua:86: in function 'fn'
    addons/adm_ulib/lua/ulib/shared/hook.lua:179: in function <addons/adm_ulib/lua/ulib/shared/hook.lua:162>
    [C]: in function '‌‎‬‪‭'


    Hud lua:
    surface.CreateFont( "Hud", {
    font = "Tahoma",
    size = 22,
    weight = 760,
    antialias = true,
    })

    surface.CreateFont( "HudSmall", {
    font = "Tahoma",
    size = 18,
    weight = 500,
    antialias = true,
    })

    local x,y = ScrW(), ScrH()
    local ply = LocalPlayer()

    --g = 50

    local function DrawHud1()

    22 stroke - draw.SimpleTextOutlined("Профессия: "..LocalPlayer():getDarkRPVar("job") or "", "Hud" ,10, y - 90, team.GetColor(ply:Team()), 0,0,1.2,Color(0,0,0))
    --g = g - 15
    draw.SimpleTextOutlined("Деньги: "..LocalPlayer():getDarkRPVar("money").." $ | +"..LocalPlayer():getDarkRPVar("salary").."$" , "Hud", 10, y - 65, Color(0,255,0,255), 0,0,1,Color(0,0,0))

    --draw.SimpleTextOutlined("$", "Hud", 8, y - 65, Color(0,255,0,255), 0,0,1,Color(0,0,0))

    draw.SimpleText(GetHostName(), "HudSmall", 10, 10, Color(255,255,255,255))
    local spacer, newx, newy = 4, 0, 0
    -- Здоровье

    local hp = math.Clamp(LocalPlayer():Health(), 0, 100)
    hr = Lerp(2 * FrameTime(), hr or 0, hp or 0)
    draw.RoundedBox(0,10,y - 40,260,10,Color(0,0,0,200))
    draw.RoundedBox(0,10,y - 40,hr * 2.6,10,Color(255,0,0,150))


    --draw.SimpleText("HP", "HudSmall", 12, y - 40, Color(255,255,255), 0, 3 )
    --draw.SimpleText(LocalPlayer():Health() or 0, "HudSmall", 120, y - 40, Color(255,255,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT )

    surface.SetDrawColor( Color(0,0,0,255) )
    surface.DrawOutlinedRect( 10,y - 40, 260, 10)
    -- newx, newy = draw.SimpleText("Броня:"..LocalPlayer():Armor().."%", "RelaxHud_BigFont", spacer, y - p ,Color(0,200,255,255),0)


    local ar = math.Clamp(LocalPlayer():Armor(), 0, 100)
    arr = Lerp(2 * FrameTime(), arr or 0, ar or 0)
    draw.RoundedBox(0,10,y - 25,260,10,Color(0,0,0,200))
    draw.RoundedBox(0,10,y - 25,arr * 2.6,10,Color(0,0,255,150))
    surface.SetDrawColor( Color(0,0,0,255) )
    surface.DrawOutlinedRect( 10, y - 25, 260, 10)

    --draw.SimpleText(" AR", "HudSmall", 140, y - 40, Color(255,255,255), 0, 3 )
    -- draw.SimpleText(LocalPlayer():Armor() or 0, "HudSmall", 140 + 115, y - 40, Color(255,255,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT )
    -- newx, newy = draw.SimpleText("Броня:"..LocalPlayer():Armor().."%", "RelaxHud_BigFont", spacer, y - p ,Color(0,200,255,255),0)


    local function MLockDown()
    if GetGlobalBool("DarkRP_LockDown") then
    local cin = (math.sin(CurTime() * 2) + 1) / 2
    --draw.RoundedBox(0,ScrW() / 2 - 180,27,365, 30, Color(cin * 255, 0, 255 - (cin * 255), 180))
    draw.SimpleText(DarkRP.getPhrase("lockdown_started"), "Hud", ScrW()/2, ScrH() - 30, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
    end
    end

    MLockDown()

    if LocalPlayer():getDarkRPVar("wanted") and LocalPlayer():getDarkRPVar("wantedReason") then
    local cin = (math.sin(CurTime() * 2) + 1) / 2
    draw.SimpleTextOutlined( "Вас разыскивают: "..tostring(LocalPlayer():getDarkRPVar("wantedReason")), "Hud", ScrW() / 2, 10, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, Color(0, 0, 0, 255))
    end
    end -- close function
    local hideHUDElements = {
    ["DarkRP_HUD"] = false, ["DarkRP_EntityDisplay"] = true, ["EntityDisplay"] = true, ["DarkRP_ZombieInfo"] = false, ["DarkRP_LocalPlayerHUD"] = true, ["DarkRP_Hungermod"] = true, ["DarkRP_Agenda"] = true, ["DarkRP_LockdownHUD"] = true, ["DarkRP_ArrestedHUD"] = false,
    }

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    hook.Add("HUDShouldDraw", "HideDefaultDarkRPHud", function(name)
    if hideHUDElements[name] or name == "CHudAmmo" or name == "CHudSecondaryAmmo" or name == "CHudHealth" then return false end
    end)

    function UDDraw()
    if not LocalPlayer():Alive() then return end

    86 stroke - DrawHud1()
    end

    hook.Add("HUDPaint", "relaxhud", UDDraw)

    local function DisplayNotify(msg)
    local txt = msg:ReadString()
    GAMEMODE:AddNotify(txt, msg:ReadShort(), msg:ReadLong())
    surface.PlaySound("buttons/lightswitch2.wav")

    MsgC(Color(255, 20, 20, 255), "[DarkRP] ", Color(200, 200, 200, 255), txt, "\n")
    end
    usermessage.Hook("_Notify", DisplayNotify)
     

Share This Page