Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[-------------------------------------------------------------------------
- BarHUD for DarkRP + Noob Friendly Config
- Developed By Derpes
- Contact Me: http://steamcommunity.com/id/TheDerpyFail
- ---------------------------------------------------------------------------]]
- if(SERVER)then
- --[[-------------------------------------------------------------------------
- SERVER CONFIGURATION
- ---------------------------------------------------------------------------]]
- --Should the user need to download fonts required? (Set to true if you don't have the 'bebasneue' font in your servers fastdl/workshop packs)
- --DEFAULT: true
- local downloadFonts = true
- --[[-------------------------------------------------------------------------
- END OF SERVER CONFIGURATION
- ---------------------------------------------------------------------------]]
- --Downloads the required fonts to the client if downloadFonts is set to true
- if(downloadFonts)then
- resource.AddSingleFile("resource/fonts/bebasneue.ttf")
- end
- elseif(CLIENT)then
- local jobBarCol--Don't touch this!
- --[[-------------------------------------------------------------------------
- CLIENT CONFIGURATION
- ---------------------------------------------------------------------------]]
- --Logo
- --Try to use 100x100 for a nice fit, you can change the size settings in the commented line within the HUDPaint hook.
- --If you know at least basic lua, use the wiki for the code shown there for help
- --DEFAULT: false
- local showLogo = false
- local logo = Material("yourpath/yourlogo.png")
- --The currency to be shown within the wallet and salary information
- local myCurrency = "$"
- --Should the job bar color be the same as the player's team color?
- --DEFAULT: true
- local jobBarTeamColor = true
- --Text shown on each bar, leave a colon and space at the end of the string to keep it looking tidy.
- local healthText = "Health: "
- local armorText = "Armor: "
- local jobText = "Job: "
- local walletText = "Wallet: "
- local ammoText = "Ammo: "
- local ammoHoldText = "Holding: "
- --Text Color Configuration
- local barTextCol = Color(255,255,255,255)--Bar statistic text color
- local barTextOutlineCol = Color(0,0,0,255)--Bar statistic text outline color
- local salaryTextCol = Color(140,220,140,255)--Color of the salary text (+$45)
- --Bar/Box Color Configuration
- local barBaseCol = Color(30,30,30,210)--Base top bar
- local barBaseOutlineCol = Color(0,130,200,255)--Base top bar outline
- local barOutlineCol = Color(0,0,0,255)--Most outer outline for each bar
- local barOutline2Col = Color(70,70,70,255)--Second most outer outline for each bar
- local healthBarCol = Color(225,50,50,255)--Health bar foreground
- local healthBarBackCol = Color(70,30,30,255)--Health bar background
- local armorBarCol = Color(50,50,225,255)--Armor bar foreground
- local armorBarBackCol = Color(30,30,70,255)--Armor bar background
- if(jobBarTeamColor)then
- jobBarCol = team.GetColor(LocalPlayer():Team())--Color of the player's team, comment this out and uncomment the one below for a set color.
- else
- jobBarCol = Color(100,100,100,255)--Job bar background
- end
- local walletBarCol = Color(120,120,20,255)--Wallet bar background
- local ammoBarCol = Color(30,30,30,255)--Ammo bar background
- --Elements that it shouldn't draw. The nasty HL2 yellow shit.
- --Stuff disappeared since adding this HUD? This is likely to be where and why.
- --true = disable it
- --false = show it
- local DerpHUDnoDraw= {
- CHudDeathNotice = true,
- CHudHealth = true,
- CHudBattery = true,
- CHudAmmo = true,
- CHudSecondaryAmmo = true,
- CHudCrosshair = true,
- CHudDamageIndicator = true,
- CHudHistoryResource = true,
- }
- --Bar Size/Space Configuration (Shouldn't change this unless you know what you're doing)
- local space = ScrW()*0.04
- local barWidth = ScrW()*0.15
- local barHeight = ScrW()*0.0167
- --[[-------------------------------------------------------------------------
- END OF CLIENT CONFIGURATION
- (If you don't know lua, I'd suggest to just NOT touch anything below here)
- ---------------------------------------------------------------------------]]
- --Convar for toggling the HUD, default visible
- CreateClientConVar("derphud_toggle","1",false,false)
- --Creating Our Fonts
- surface.CreateFont("barFont",{font="bebasneue",size=22,weight=500})
- surface.CreateFont("barFontSmall",{font="bebasneue",size=17,weight=500})
- --Initialize the smooth variables so they don't return as nil
- local smoothHealth = 0
- local smoothArmor = 0
- --The paint hook, all the goodies
- hook.Add("HUDPaint","derp_mainHUD",function()
- --Check if the HUD is toggled before drawing it
- if (GetConVarNumber("derphud_toggle")==0)then return end
- --Drawing Base
- draw.RoundedBox(0,0,0,ScrW(),ScrH()*0.04,barBaseCol)
- surface.SetDrawColor(barBaseOutlineCol)
- surface.DrawOutlinedRect(-2,-2,ScrW()+4,ScrH()*0.04+3)
- --Drawing Logo
- if(showLogo)then
- surface.SetDrawColor(255,255,255,150)
- surface.SetMaterial(logo)
- surface.DrawTexturedRect(10,ScrH()-110,100,100)
- end
- --Creating a variable to make the health/armor bars increase/decrease with a smooth animation
- smoothHealth = math.Approach(smoothHealth,math.Clamp(LocalPlayer():Health(),0,100),50*FrameTime())
- smoothArmor = math.Approach(smoothArmor,math.Clamp(LocalPlayer():Armor(),0,100),50*FrameTime())
- --Drawing Health Information
- draw.RoundedBox(0,space,5,barWidth,barHeight,barOutlineCol)
- draw.RoundedBox(0,space+1,6,barWidth-2,barHeight-2,barOutline2Col)
- draw.RoundedBox(0,space+2,7,barWidth-4,barHeight-4,healthBarBackCol)
- local mathHealth = (barWidth-8)*(smoothHealth/100)+8
- draw.RoundedBox(0,space+4,9,mathHealth-8,barHeight-8,healthBarCol)
- draw.SimpleTextOutlined(healthText..LocalPlayer():Health() or 0,"barFont",(space+4)+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
- --Drawing Armor Information
- draw.RoundedBox(0,(space*2)+barWidth,5,barWidth,barHeight,barOutlineCol)
- draw.RoundedBox(0,(space*2)+barWidth+1,6,barWidth-2,barHeight-2,barOutline2Col)
- draw.RoundedBox(0,(space*2)+barWidth+2,7,barWidth-4,barHeight-4,armorBarBackCol)
- local mathArmor = (barWidth-8)*(smoothArmor/100)+8
- draw.RoundedBox(0,(space*2)+barWidth+4,9,mathArmor-8,barHeight-8,armorBarCol)
- draw.SimpleTextOutlined(armorText..LocalPlayer():Armor() or 0,"barFont",space*2+barWidth+4+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
- --Drawing Job Information
- draw.RoundedBox(0,(space*3)+(barWidth*2),5,barWidth,barHeight,barOutlineCol)
- draw.RoundedBox(0,(space*3)+(barWidth*2)+1,6,barWidth-2,barHeight-2,barOutline2Col)
- draw.RoundedBox(0,(space*3)+(barWidth*2)+2,7,barWidth-4,barHeight-4,jobBarCol)
- draw.SimpleTextOutlined(jobText..LocalPlayer():getDarkRPVar("job") or "","barFont",space*3+(barWidth*2)+4+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
- --Drawing Wallet & Sallery Information
- draw.RoundedBox(0,(space*4)+(barWidth*3),5,barWidth,barHeight,barOutlineCol)
- draw.RoundedBox(0,(space*4)+(barWidth*3)+1,6,barWidth-2,barHeight-2,barOutline2Col)
- draw.RoundedBox(0,(space*4)+(barWidth*3)+2,7,barWidth-4,barHeight-4,walletBarCol)
- draw.SimpleTextOutlined(walletText..myCurrency..LocalPlayer():getDarkRPVar("money") or 0,"barFont",space*4+(barWidth*3)+4+(barWidth/2),20,barTextCol,1,1,1,barTextOutlineCol)
- draw.SimpleTextOutlined("+ "..myCurrency..LocalPlayer():getDarkRPVar("salary") or 0,"barFontSmall",space*4+(barWidth*3)+4+(barWidth/1.05),20,salaryTextCol,TEXT_ALIGN_RIGHT,1,1,barTextOutlineCol)
- --Drawing Ammo Information
- draw.RoundedBox(0,(space*5)+(barWidth*4),5,barWidth,barHeight,barOutlineCol)
- draw.RoundedBox(0,(space*5)+(barWidth*4)+1,6,barWidth-2,barHeight-2,barOutline2Col)
- draw.RoundedBox(0,(space*5)+(barWidth*4)+2,7,barWidth-4,barHeight-4,ammoBarCol)
- if(LocalPlayer():GetActiveWeapon():Clip1()!=-1)then
- draw.SimpleTextOutlined(ammoText.. LocalPlayer():GetActiveWeapon():Clip1() .. "/" .. LocalPlayer():GetAmmoCount( LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType() ),"barFont",space*5+(barWidth*4)+4+(barWidth/2),20,barTextCol,1,1,barTextOutlineCol)
- else
- if(LocalPlayer():GetActiveWeapon():GetPrintName()!=nil)then
- draw.SimpleTextOutlined(ammoHoldText..LocalPlayer():GetActiveWeapon():GetPrintName(),"barFont",space*5+(barWidth*4)+4+(barWidth/2),20,barTextCol,1,1,barTextOutlineCol)
- end
- end
- end)
- --Disabling elements configured within the clientside configuration
- hook.Add("HUDShouldDraw","HideHUDDefaultGmodYellowShit",function(name)
- if(DerpHUDnoDraw[name])then return false end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement