Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------
- HUD ConVars
- ---------------------------------------------------------------------------*/
- local ConVars = {}
- local HUDWidth
- local HUDHeight
- local RelativeX
- local RelativeY
- local function ReloadConVars()
- ConVars = {
- background = Color(0,0,0,100),
- Healthbackground = Color(0,0,0,200),
- Healthforeground = Color(140,0,0,180),
- HealthText = Color(255,255,255,200),
- Job1 = Color(0,0,150,200),
- Job2 = Color(0,0,0,255),
- salary1 = Color(0,150,0,200),
- salary2 = Color(0,0,0,255)
- }
- RelativeX = 0
- RelativeY = 40
- HUDWidth = ScrW()
- HUDHeight = ScrH()/20
- //HUDWidth = (GetConVar("HudW") or CreateClientConVar("HudW", 240, true, false)):GetInt()
- //HUDHeight = ((GetConVar("HudH") or CreateClientConVar("HudH", 115, true, false)):GetInt()+15)
- end
- ReloadConVars()
- //local Scrw, Scrh, RelativeX, RelativeY
- /*---------------------------------------------------------------------------
- HUD Seperate Elements
- ---------------------------------------------------------------------------*/
- local Health = 0
- local function DrawHealth(offset)
- offset=offset or 80
- Health = (Health == LocalPlayer():Health() and Health) or Lerp(0.1, Health, LocalPlayer():Health())
- local DrawHealth = math.Clamp(Health / GetConVarNumber("startinghealth"), 0, 1)
- local Border = math.Min(6, math.pow(2, math.Round(3*DrawHealth)))
- draw.DrawText("Health", "TargetID", RelativeX + offset-40+4+6, RelativeY - 32, Color(255, 255, 255, 255), 1)
- draw.RoundedBox(Border, RelativeX + offset+4, RelativeY - 30, /*HUDWidth - 8 -*/ ScrW()/5-8, 20, Color(0,0,0,200))
- draw.RoundedBox(Border, RelativeX + offset+5, RelativeY - 29, /*(HUDWidth - 9)*/ (ScrW()/5-9) * DrawHealth, 18, Color(140,0,0,180))
- draw.DrawText(math.Max(0, math.Round(Health)), "TargetID", RelativeX + offset+4 + (ScrW()/5-8)/2, RelativeY - 32, Color(255, 255, 255, 255), 1)
- end
- local function DrawInfo()
- local ply = LocalPlayer()
- local Salary
- if ply:EV_GetRank()=="donator" or ply:IsAdmin() or ply:IsSuperAdmin() then
- Salary = LANGUAGE.salary .. CUR .. (LocalPlayer().DarkRPVars.salary.." (x2)" or 0)
- else
- Salary = LANGUAGE.salary .. CUR .. (LocalPlayer().DarkRPVars.salary or 0)
- end
- /*local JobWallet = // old wallet stuff
- LANGUAGE.job .. (LocalPlayer().DarkRPVars.job or "") .. "\n"..
- LANGUAGE.wallet .. CUR .. (LocalPlayer().DarkRPVars.money or 0).."\n"..
- LANGUAGE.points .. (LocalPlayer().DarkRPVars.points or 0)
- */
- draw.TexturedQuad({
- texture=surface.GetTextureID("gui/silkicons/"..evolve.ranks[LocalPlayer():EV_GetRank()].Icon),
- //texture="gui/gradient",
- //color=Color(255, 255, 255, 255),
- x=ScrW()/20-32,
- y=RelativeY-30,
- w=16,
- h=16
- })
- draw.DrawText(LocalPlayer():Nick(), "TargetID", ScrW()/20-10, RelativeY - 32, Color(255, 255, 255, 255), 0)
- surface.SetFont("TargetID")
- local w, h = surface.GetTextSize(Salary)
- draw.DrawText(LANGUAGE.job .. (LocalPlayer().DarkRPVars.job or ""), "TargetID", RelativeX + (ScrW()/10)*5, RelativeY - 32, Color(255, 255, 255, 255), 0)
- end
- local function GunLicense()
- if LocalPlayer().DarkRPVars.HasGunlicense then
- local QuadTable = {}
- QuadTable.texture = surface.GetTextureID( "gui/silkicons/page" )
- QuadTable.color = Color( 255, 255, 255, 100 )
- QuadTable.x = RelativeX + HUDWidth + 31
- QuadTable.y = ScrH() - 32
- QuadTable.w = 32
- QuadTable.h = 32
- draw.TexturedQuad(QuadTable)
- end
- end
- local function JobHelp()
- local Helps = {"Cop", "Mayor", "Admin", "Boss"}
- for k,v in pairs(Helps) do
- if LocalPlayer().DarkRPVars["help"..v] then
- draw.RoundedBox(10, 10, 10, 590, 194, Color(0, 0, 0, 255))
- draw.RoundedBox(10, 12, 12, 586, 190, Color(51, 58, 51, 200))
- draw.RoundedBox(10, 12, 12, 586, 20, Color(0, 0, 70, 200))
- draw.DrawText(v.." Help", "ScoreboardText", 30, 12, Color(255,0,0,255),0)
- draw.DrawText(string.format(LANGUAGE[v:lower().."help"], GetConVarNumber("jailtimer")), "ScoreboardText", 30, 35, Color(255,255,255,255),0)
- end
- end
- end
- local function Agenda()
- local HUDHeight2=HUDHeight+10
- local DrawAgenda, AgendaManager = DarkRPAgendas[LocalPlayer():Team()], LocalPlayer():Team()
- if not DrawAgenda then
- for k,v in pairs(DarkRPAgendas) do
- if table.HasValue(v.Listeners, LocalPlayer():Team()) then
- DrawAgenda, AgendaManager = DarkRPAgendas[k], k
- break
- end
- end
- end
- if DrawAgenda then
- draw.RoundedBox(10, 10, 10, 460, 110+HUDHeight2, Color(0, 0, 0, 155))
- draw.RoundedBox(10, 12, 12, 456, 106+HUDHeight2, Color(51, 58, 51,100))
- draw.RoundedBox(10, 12, 12, 456, 20+HUDHeight2, Color(0, 0, 70, 100))
- draw.DrawText(DrawAgenda.Title, "ScoreboardText", 30, 12+HUDHeight2, Color(255,0,0,255),0)
- local AgendaText = ""
- for k,v in pairs(team.GetPlayers(AgendaManager)) do
- AgendaText = AgendaText .. (v.DarkRPVars.agenda or "")
- end
- draw.DrawText(string.gsub(string.gsub(AgendaText, "//", "\n"), "\\n", "\n"), "ScoreboardText", 30, 35+HUDHeight2, Color(255,255,255,255),0)
- end
- end
- 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(surface.GetTextureID( "voice/icntlk_pl" ))
- surface.SetDrawColor(ConVars.Healthforeground)
- surface.DrawTexturedRectRotated(ScrW() - 100, chboxY, Rotating*96, 96, backwards)
- end
- end
- local function LockDown()
- local chbxX, chboxY = chat.GetChatBoxPos()
- if tobool(GetConVarNumber("DarkRP_LockDown")) then
- local cin = (math.sin(CurTime()) + 1) / 2
- draw.DrawText(LANGUAGE.lockdown_started, "ScoreboardSubtitle", chbxX, chboxY + 260, 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().DarkRPVars.Arrested then
- draw.DrawText(string.format(LANGUAGE.youre_arrested, math.ceil(ArrestedUntil - (CurTime() - StartArrested))), "ScoreboardText", ScrW()/2, ScrH() - ScrH()/12, Color(255,255,255,255), 1)
- elseif not LocalPlayer().DarkRPVars.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, 255))
- draw.DrawText(LANGUAGE.listen_up, "GModToolName", ScrW() / 2 + 10, 10, Color(255, 255, 255, 255), 1)
- draw.DrawText(Message, "ChatFont", ScrW() / 2 + 10, 65, Color(200, 30, 30, 255), 1)
- end
- timer.Simple(10, function()
- AdminTell = function() end
- end)
- end)
- /*---------------------------------------------------------------------------
- Drawing the HUD elements such as Health etc.
- ---------------------------------------------------------------------------*/
- local function DrawHUD()
- --Background
- draw.RoundedBox(0, RelativeX, RelativeY-40, HUDWidth, HUDHeight, Color(40,40,40,200))
- DrawHealth(ScrW()/5)
- DrawInfo()
- draw.RoundedBox(0, RelativeX, RelativeY-40, HUDWidth, HUDHeight/2, Color(255,255,255,50))
- GunLicense()
- Agenda()
- JobHelp()
- DrawVoiceChat()
- LockDown()
- Arrested()
- AdminTell()
- end
- /*---------------------------------------------------------------------------
- Entity HUDPaint things
- ---------------------------------------------------------------------------*/
- local function DrawPlayerInfo(ply)
- local pos = ply:EyePos()
- pos.z = pos.z + 34
- pos = pos:ToScreen()
- if GetConVarNumber("nametag") == 1 then
- draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
- draw.DrawText(ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor(ply:Team()), 1)
- draw.DrawText(LANGUAGE.health ..ply:Health(), "TargetID", pos.x + 1, pos.y + 21, Color(0, 0, 0, 255), 1)
- draw.DrawText(LANGUAGE.health..ply:Health(), "TargetID", pos.x, pos.y + 20, Color(255,255,255,200), 1)
- end
- if GetConVarNumber("jobtag") == 1 then
- draw.DrawText(ply.DarkRPVars.job or "", "TargetID", pos.x + 1, pos.y + 41, Color(0, 0, 0, 255), 1)
- draw.DrawText(ply.DarkRPVars.job or "", "TargetID", pos.x, pos.y + 40, Color(255, 255, 255, 200), 1)
- end
- if ply.DarkRPVars.HasGunlicense then
- surface.SetTexture(surface.GetTextureID("gui/silkicons/page"))
- surface.SetDrawColor(255,255,255,255)
- surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
- end
- end
- local function DrawWantedInfo(ply)
- if not ply:Alive() then return end
- local pos = ply:EyePos()
- if not pos:RPIsInSight({LocalPlayer(), ply}) then return end
- pos.z = pos.z + 14
- pos = pos:ToScreen()
- if GetConVarNumber("nametag") == 1 then
- draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1)
- draw.DrawText(ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor(ply:Team()), 1)
- end
- draw.DrawText(LANGUAGE.wanted.."\nReason: "..tostring(ply.DarkRPVars["wantedReason"]), "TargetID", pos.x, pos.y - 40, Color(255, 255, 255, 200), 1)
- draw.DrawText(LANGUAGE.wanted.."\nReason: "..tostring(ply.DarkRPVars["wantedReason"]), "TargetID", pos.x + 1, pos.y - 41, Color(255, 0, 0, 255), 1)
- end
- /*---------------------------------------------------------------------------
- The Entity display: draw HUD information about entities
- ---------------------------------------------------------------------------*/
- local function DrawEntityDisplay()
- for k, ply in pairs(player.GetAll()) do
- if not ply:Alive() then continue end
- ply.DarkRPVars = ply.DarkRPVars or {}
- if ply.DarkRPVars.wanted then DrawWantedInfo(ply) end
- if GetConVarNumber("globalshow") == 1 and ply ~= LocalPlayer() then DrawPlayerInfo(ply) end
- end
- local tr = LocalPlayer():GetEyeTrace()
- if tr.Entity and tr.Entity.IsValid and ValidEntity(tr.Entity) and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 400 then
- if tr.Entity:IsPlayer() and not tobool(GetConVarNumber("globalshow")) then
- DrawPlayerInfo(tr.Entity)
- end
- end
- if tr.Entity:IsOwnable() then
- tr.Entity:DrawOwnableInfo()
- end
- end
- /*---------------------------------------------------------------------------
- Zombie display
- ---------------------------------------------------------------------------*/
- local function DrawZombieInfo()
- if not LocalPlayer().DarkRPVars.zombieToggle then return end
- for x=1, LocalPlayer().DarkRPVars.numPoints, 1 do
- local zPoint = LocalPlayer().DarkRPVars["zPoints".. x]
- if zPoint then
- zPoint = zPoint:ToScreen()
- draw.DrawText("Zombie Spawn (" .. x .. ")", "TargetID", zPoint.x, zPoint.y - 20, Color(255, 255, 255, 200), 1)
- draw.DrawText("Zombie Spawn (" .. x .. ")", "TargetID", zPoint.x + 1, zPoint.y - 21, Color(255, 0, 0, 255), 1)
- end
- end
- end
- /*---------------------------------------------------------------------------
- Actual HUDPaint hook
- ---------------------------------------------------------------------------*/
- function GAMEMODE:HUDPaint()
- if GetConVarNumber("cl_drawhud") >= 1 then
- DrawHUD()
- DrawZombieInfo()
- DrawEntityDisplay()
- self.BaseClass:HUDPaint()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment