Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hideHUDElements = {
- -- if you DarkRP_HUD this to true, ALL of DarkRP's HUD will be disabled. That is the health bar and stuff,
- -- but also the agenda, the voice chat icons, lockdown text, player arrested text and the names above players' heads
- ["DarkRP_HUD"] = true,
- -- DarkRP_EntityDisplay is the text that is drawn above a player when you look at them.
- -- This also draws the information on doors and vehicles
- ["DarkRP_EntityDisplay"] = true,
- -- DarkRP_ZombieInfo draws information about zombies for admins who use /showzombie.
- ["DarkRP_ZombieInfo"] = false,
- -- This is the one you're most likely to replace first
- -- DarkRP_LocalPlayerHUD is the default HUD you see on the bottom left of the screen
- -- It shows your health, job, salary and wallet
- ["DarkRP_LocalPlayerHUD"] = true,
- ["DarkRP_Hungermod"] = true,
- -- Drawing the DarkRP agenda
- ["DarkRP_Agenda"] = false,
- ["CHudAmmo"] = true,
- }
- -- hide shitty overhead sprite
- timer.Simple(2, function()
- Material("voice/icntlk_pl"):SetFloat("$alpha", 0)
- end)
- hook.Add("ShutDown", "voice/icntlk_pl", function()
- Material("voice/icntlk_pl"):SetFloat("$alpha", 1)
- end)
- local scale = 1
- local shadow_x = 1*scale -- I left 1 to make it noticeble
- local shadow_y = 1*scale
- local col_face = Color(255,255,255,255)
- local col_shadow = Color(0,0,0,255)
- local col_half_shadow = Color(0,0,0,200)
- local col_money = Color(64,192,32)
- -- this is the code that actually disables the drawing.
- hook.Add("HUDShouldDraw", "HideDefaultDarkRPHud", function(name)
- if hideHUDElements[name] then return false end
- end)
- surface.CreateFont("nx_hud_time", {
- size = 35 * scale,
- weight = 350 * scale,
- antialias = true,
- extended = true,
- font = "Roboto"})
- surface.CreateFont("nx_hud_time_shadow", {
- size = 35 * scale,
- weight = 350 * scale,
- antialias = true,
- blursize = 3 * scale,
- extended = true,
- font = "Roboto"})
- surface.CreateFont("nx_hud_ammo", {
- size = 42 * scale,
- weight = 350 * scale,
- antialias = true,
- extended = true,
- font = "Roboto"})
- surface.CreateFont("nx_hud_ammo_shadow", {
- size = 42 * scale,
- weight = 350 * scale,
- antialias = true,
- blursize = 3 * scale,
- extended = true,
- font = "Roboto"})
- surface.CreateFont("nx_hud", {
- size = 22 * scale,
- weight = 350 * scale,
- antialias = true,
- extended = true,
- font = "Roboto"})
- surface.CreateFont("nx_hud_shadow", {
- size = 22 * scale,
- weight = 350 * scale,
- antialias = true,
- blursize = 3 * scale,
- extended = true,
- font = "Roboto"})
- surface.CreateFont("nx_hud_icon", {
- size = 48 * scale,
- weight = 350 * scale,
- antialias = true,
- extended = true,
- font = NX_ICONFONT})
- surface.CreateFont("nx_hud_icon_shadow", {
- size = 48 * scale,
- weight = 350 * scale,
- antialias = true,
- blursize = 3 * scale,
- extended = true,
- font = NX_ICONFONT})
- -- why dont we just multiply size by align coeff. and add it to position ?
- -- its simple.. see BeautyText
- local ALIGN_LEFT = 0
- local ALIGN_CENTER = 0.5
- local ALIGN_RIGHT = 1
- local ALIGN_TOP = 1
- local ALIGN_BOTTOM = 0
- local function SimpleText(str, font, ...)
- error "plsno"
- draw.SimpleText(str, font, ...)
- return surface.GetTextSize(str)
- end
- local function BeautyText( str, font, font_shadow, x, y, color, xalign, yalign )
- font = font or "nx_hud"
- surface.SetFont( font )
- local tw, th = surface.GetTextSize( str )
- x = (x or 0) - tw * (xalign or 0)
- y = (y or 0) - th * (yalign or 0)
- surface.SetTextPos( x, y )
- -- sorf shadow:
- if font_shadow then
- surface.SetTextPos( x, y+3 )
- surface.SetTextColor( col_shadow )
- surface.SetFont( font_shadow )
- surface.DrawText( str )
- surface.SetTextPos( x, y )
- end
- -- sharp shadow:
- surface.SetTextPos( x + shadow_x , y + shadow_y )
- surface.SetTextColor( col_half_shadow )
- surface.SetFont( font )
- surface.DrawText( str )
- -- text itself:
- surface.SetTextColor( color or col_face )
- surface.SetTextPos( x, y )
- surface.DrawText( str )
- return tw,th
- end
- local function WideBar(num, max, w, color, x, y)
- local h = 22 * scale
- local o = BeautyText(num .. "%", "nx_hud", "nx_hud_shadow", x, y, color, ALIGN_LEFT, ALIGN_TOP) + 4 * scale
- x = x + o
- surface.SetDrawColor(ColorAlpha(color, 64))
- surface.DrawRect(x, y - h + h/4, w * scale, h/2)
- surface.SetDrawColor(color)
- surface.DrawRect(x, y - h + h/4, w * math.max(0, math.min(1, num/max)) * scale, h/2)
- return o + w * scale, h
- end
- local x, y, i_am_the_greatest, seen_anything = 0, 0, 0
- local function yield(w, h)
- x = x + w
- i_am_the_greatest = math.max(i_am_the_greatest, h)
- seen_anything = true
- end
- local function space()
- x = x + 8 * scale
- end
- local hud = {}
- local function Row(...)
- table.insert(hud, {...})
- end
- local hunger_alpha = 0
- local extraArmor = 0
- Row ( -- Character info
- function() -- Health
- yield(BeautyText(DarkRP.getPhrase("health", ""), "nx_hud", "nx_hud_shadow", x, y, color_white, ALIGN_LEFT, ALIGN_TOP))
- yield(WideBar(LocalPlayer():Health(), LocalPlayer():GetMaxHealth(), 100, HSVToColor(math.Clamp(LocalPlayer():Health(), 0, LocalPlayer():GetMaxHealth()) / LocalPlayer():GetMaxHealth() * 120, 1, 1), x, y))
- end,
- function() -- Armour
- local amount = LocalPlayer():Armor() * 2
- if amount > 100 then
- extraArmor = math.min(1, extraArmor + RealFrameTime())
- else
- extraArmor = math.max(0, extraArmor - RealFrameTime())
- end
- if amount > 0 then
- yield(BeautyText(DarkRP.getPhrase("armor"), "nx_hud", "nx_hud_shadow", x, y, color_white, ALIGN_LEFT, ALIGN_TOP))
- yield(WideBar(amount, 100 * (1+extraArmor), 100 * (1+extraArmor), HSVToColor(math.Clamp(amount, 0, 100) * 1.2, 1, 1), x, y))
- end
- end,
- --not GAMEMODE.Config.DisabledModules.hungermod
- --and
- function() -- Hunger
- --local energy = math.floor(LocalPlayer():GetStat"energy":Get() or 0)
- local energy = LocalPlayer():getDarkRPVar("Energy")
- yield(BeautyText("Голод: ", "nx_hud", "nx_hud_shadow", x, y, Color(255, 255, 255, 255), ALIGN_LEFT, ALIGN_TOP))
- yield(WideBar((100 - energy), 100, 100, HSVToColor(energy * 1.2, 1, 1), x, y))
- end
- --or nil
- )
- local money_last = 0
- local money_alpha = 0
- local money_alpha_positive = true
- local color_blend = Color(64, 128, 64)
- local function getmoney()
- if LocalPlayer():GetNWBool("fun_money111") then
- return 0
- else
- return LocalPlayer():getDarkRPVar("money", 0) or 0
- end
- end
- Row ( -- Wallet
- function()
- yield(BeautyText(LocalPlayer():getDarkRPVar("job") or "", "nx_hud", "nx_hud_shadow", x, y, team.GetColor(LocalPlayer():Team()), ALIGN_LEFT, ALIGN_TOP))
- space()
- if money_last ~= getmoney() then
- if getmoney() >= (money_last or 0) then
- color_blend.r = 0
- color_blend.g = 255
- color_blend.b = 0
- else
- color_blend.r = 255
- color_blend.g = 0
- color_blend.b = 0
- end
- money_last = getmoney()
- end
- local dt = RealFrameTime() * 0.5
- color_blend.r = Lerp(dt, color_blend.r, 0)
- color_blend.g = Lerp(dt, color_blend.g, 128)
- color_blend.b = Lerp(dt, color_blend.b, 255)
- yield(BeautyText(DarkRP.formatMoney(getmoney()), "nx_hud", "nx_hud_shadow", x, y, color_blend, ALIGN_LEFT, ALIGN_TOP))
- end
- )
- --[[
- xpcall(function()
- local name, fun = debug.getupvalue(select(2, debug.getupvalue(GAMEMODE.HUDPaint, 1)), 19)
- assert(name == "LockDown")
- debug.setupvalue(select(2, debug.getupvalue(GAMEMODE.HUDPaint, 1)), 19, function() end)
- end, Error)
- ]]
- Row ( -- Lockdown
- function()
- if GetGlobalBool("DarkRP_LockDown") then
- local cin = (math.sin(CurTime()) + 1) / 2
- yield(BeautyText(DarkRP.getPhrase("lockdown_started"), "nx_hud", "nx_hud_shadow", x, y, Color(cin * 255, 0, 255 - (cin * 255)), 0, ALIGN_TOP))
- end
- end
- )
- -- Row ( -- Taxi
- -- function()
- -- local car = LocalPlayer():GetVehicle()
- -- if not car:IsValid() then
- -- return
- -- end
- -- car = car:GetParent():IsValid() and car:GetParent() or car
- -- if car:IsValid() and car:GetNWBool("TaxiCar") then
- -- yield(BeautyText(DarkRP.getPhrase("path"), "nx_hud", "nx_hud_shadow", x, y, color_white, 0, ALIGN_TOP))
- -- local km, pathStr = math.sqrt(LocalPlayer():GetNetworkedFloat("TaxiPath", 0)) / 524.9344
- -- local price = math.ceil(km * car:GetNWFloat("TaxiPrice"))
- -- if km < 1 then
- -- pathStr = DarkRP.getPhrase("m", math.floor(km * 1000))
- -- else
- -- pathStr = DarkRP.getPhrase("km", math.floor(km * 100) * 0.01)
- -- end
- -- yield(BeautyText(pathStr .. ", " .. DarkRP.formatMoney(price), "nx_hud", "nx_hud_shadow", x, y, Color(150, 255, 150), 0, ALIGN_TOP))
- -- end
- -- end
- -- )
- Row ( -- Voice
- function()
- if LocalPlayer():IsSpeaking() then
- local sine = HSVToColor(200, math.abs(math.sin(RealTime()*2)), 1)
- yield(BeautyText("g", "nx_hud_icon", "nx_hud_icon_shadow", x, y, sine, 0.2, ALIGN_TOP))
- end
- end
- )
- Row ( -- Stats
- function ()
- if playerstats then
- yield( playerstats.DrawHUD(x,y) )
- end
- end
- )
- hook.Add("HUDPaint", "DarkRP_Mod_HUDPaint", function()
- if LocalPlayer():Health() <= 0 then return end
- if hook.Run("HUDShouldDraw", "Noiwex HUD") == false then
- return
- end
- local offy, offx, space_width = ScrH() - 8, 8, 8
- x, y = offx, offy
- for _, row in pairs(hud) do
- for _, fn in pairs(row) do
- seen_anything = false
- xpcall(fn, Error)
- if seen_anything then
- space()
- end
- end
- offy = offy - i_am_the_greatest
- i_am_the_greatest = 0
- y = offy
- x = offx
- end
- end)
- local insuff_ammo1, insuff_ammo2 = 1, 1
- hook.Add("HUDPaint", "DarkRP_Mod_HUDPaint_Ammo", function()
- if hook.Run("HUDShouldDraw", "Noiwex HUD Ammo") == false then
- return
- end
- local wep = LocalPlayer():GetActiveWeapon()
- if not IsValid(wep) or wep:GetPrimaryAmmoType() < 0 then
- return
- end
- local ammo1 = wep:Clip1()
- local ammo2 = LocalPlayer():GetAmmoCount(wep:GetPrimaryAmmoType())
- if ammo1 < 0 then
- ammo1 = nil
- end
- local offy, offx, space_width = ScrH() - 8, (minimap and minimap.x or ScrW()) - 24, 8
- if ammo1 == 0 then
- insuff_ammo1 = math.max(insuff_ammo1 - RealFrameTime(), 0)
- else
- insuff_ammo1 = math.min(insuff_ammo1 + RealFrameTime(), 1)
- end
- if ammo2 == 0 then
- insuff_ammo2 = math.max(insuff_ammo2 - RealFrameTime(), 0)
- else
- insuff_ammo2 = math.min(insuff_ammo2 + RealFrameTime(), 1)
- end
- offx = offx - BeautyText((ammo1 and " / " or "") .. ammo2, "nx_hud_ammo", "nx_hud_ammo_shadow", offx, offy, Color(255, insuff_ammo2 * 255, insuff_ammo2 * 255), ALIGN_RIGHT, ALIGN_TOP)
- offx = offx - BeautyText(ammo1 or "", "nx_hud_time", "nx_hud_time_shadow", offx, offy - 3, Color(255, insuff_ammo1 * 255, insuff_ammo1 * 255), ALIGN_RIGHT, ALIGN_TOP)
- end)
- usermessage.Hook("AteFoodIcon", function()
- hunger_alpha = RealTime()
- end)
Advertisement
Add Comment
Please, Sign In to add comment