Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------
- SmurfRP by j0rpi
- File: hud.lua
- Purpose: Handles everything on the screen
- ---------------------------------------------------------------------------*
- /*--------------------------------------------------------------------------
- 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
- local version = ""
- CreateClientConVar("weaponhud", 0, true, false)
- local useIsAdminCheck = false -- Disable this if you want to use custom admin groups
- local adminGroups = {
- ["superadmin"] = true,
- ["senior-admin"] = true,
- ["admin"] = true,
- ["moderator"] = true,
- }
- 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 tblFonts = { }
- tblFonts["DebugFixed"] = {
- font = "Courier New",
- size = 10,
- weight = 500,
- antialias = true,
- }
- tblFonts["DebugFixedSmall"] = {
- font = "Courier New",
- size = 7,
- weight = 500,
- antialias = true,
- }
- tblFonts["DefaultFixedOutline"] = {
- font = "Lucida Console",
- size = 10,
- weight = 0,
- outline = true,
- }
- tblFonts["MenuItem"] = {
- font = "Tahoma",
- size = 12,
- weight = 500,
- }
- tblFonts["Default"] = {
- font = "Tahoma",
- size = 13,
- weight = 500,
- }
- tblFonts["TabLarge"] = {
- font = "Tahoma",
- size = 13,
- weight = 700,
- shadow = true,
- }
- tblFonts["DefaultBold"] = {
- font = "Tahoma",
- size = 13,
- weight = 1000,
- }
- tblFonts["DefaultUnderline"] = {
- font = "Tahoma",
- size = 13,
- weight = 500,
- underline = true,
- }
- tblFonts["DefaultSmall"] = {
- font = "Tahoma",
- size = 1,
- weight = 0,
- }
- tblFonts["DefaultSmallDropShadow"] = {
- font = "Tahoma",
- size = 11,
- weight = 0,
- shadow = true,
- }
- tblFonts["DefaultVerySmall"] = {
- font = "Tahoma",
- size = 12,
- weight = 600,
- outline = true,
- }
- tblFonts["DefaultLarge"] = {
- font = "Tahoma",
- size = 16,
- weight = 0,
- }
- tblFonts["UiBold"] = {
- font = "Tahoma",
- size = 12,
- weight = 1000,
- }
- tblFonts["MenuLarge"] = {
- font = "Verdana",
- size = 15,
- weight = 600,
- antialias = true,
- }
- tblFonts["ConsoleText"] = {
- font = "Lucida Console",
- size = 10,
- weight = 500,
- }
- tblFonts["Marlett"] = {
- font = "Marlett",
- size = 13,
- weight = 0,
- symbol = true,
- }
- tblFonts["Trebuchet24"] = {
- font = "Trebuchet MS",
- size = 24,
- weight = 900,
- }
- tblFonts["Trebuchet22"] = {
- font = "Trebuchet MS",
- size = 22,
- weight = 900,
- }
- tblFonts["Trebuchet20"] = {
- font = "Trebuchet MS",
- size = 20,
- weight = 900,
- }
- tblFonts["Trebuchet19"] = {
- font = "Trebuchet MS",
- size = 19,
- weight = 900,
- }
- tblFonts["Trebuchet18"] = {
- font = "Trebuchet MS",
- size = 18,
- weight = 900,
- }
- tblFonts["HUDNumber"] = {
- font = "Trebuchet MS",
- size = 40,
- weight = 900,
- }
- tblFonts["HUDNumber1"] = {
- font = "Trebuchet MS",
- size = 41,
- weight = 900,
- }
- tblFonts["HUDNumber2"] = {
- font = "Trebuchet MS",
- size = 42,
- weight = 900,
- }
- tblFonts["HUDNumber3"] = {
- font = "Trebuchet MS",
- size = 43,
- weight = 900,
- }
- tblFonts["HUDNumber4"] = {
- font = "Trebuchet MS",
- size = 44,
- weight = 900,
- }
- tblFonts["HUDNumber5"] = {
- font = "Trebuchet MS",
- size = 45,
- weight = 900,
- }
- tblFonts["HudHintTextLarge"] = {
- font = "Verdana",
- size = 14,
- weight = 1000,
- antialias = true,
- additive = true,
- }
- tblFonts["HudHintTextSmall"] = {
- font = "Verdana",
- size = 11,
- weight = 0,
- antialias = true,
- additive = true,
- }
- tblFonts["CenterPrintText"] = {
- font = "Trebuchet MS",
- size = 18,
- weight = 900,
- antialias = true,
- additive = true,
- }
- tblFonts["DefaultFixed"] = {
- font = "Lucida Console",
- size = 10,
- weight = 0,
- }
- tblFonts["DefaultFixedDropShadow"] = {
- font = "Lucida Console",
- size = 10,
- weight = 0,
- shadow = true,
- }
- tblFonts["CloseCaption_Normal"] = {
- font = "Tahoma",
- size = 16,
- weight = 500,
- }
- tblFonts["CloseCaption_Italic"] = {
- font = "Tahoma",
- size = 16,
- weight = 500,
- italic = true,
- }
- tblFonts["CloseCaption_Bold"] = {
- font = "Tahoma",
- size = 16,
- weight = 900,
- }
- tblFonts["CloseCaption_BoldItalic"] = {
- font = "Tahoma",
- size = 16,
- weight = 900,
- italic = true,
- }
- tblFonts["TargetID"] = {
- font = "Trebuchet MS",
- size = 22,
- weight = 900,
- antialias = true,
- }
- tblFonts["TargetIDSmall"] = {
- font = "Trebuchet MS",
- size = 18,
- weight = 900,
- antialias = true,
- }
- tblFonts["BudgetLabel"] = {
- font = "Courier New",
- size = 14,
- weight = 400,
- outline = true,
- }
- tblFonts["j0rpi"] = {
- font = "Tahoma",
- size = 23,
- weight = 200,
- antialias = false,
- shadow = false,
- outline = true,
- }
- tblFonts["j0rpi2"] = {
- font = "Tahoma",
- size = 14,
- weight = 200,
- antialias = false,
- shadow = false,
- outline = true,
- }
- tblFonts["j0rpi3"] = {
- font = "Tahoma",
- size = 14,
- weight = 900,
- antialias = true,
- shadow = false,
- outline = false,
- }
- tblFonts["j0rpi4"] = {
- font = "Tahoma",
- size = 18,
- weight = 600,
- antialias = false,
- shadow = false,
- outline = true,
- }
- tblFonts["j0rpi5"] = {
- font = "Tahoma",
- size = 12,
- weight = 600,
- antialias = true,
- shadow = false,
- outline = true,
- }
- tblFonts["j0rpi6"] = {
- font = "Tahoma",
- size = 16,
- weight = 600,
- antialias = false,
- shadow = false,
- outline = true,
- }
- tblFonts["j0rpi7"] = {
- font = "Tahoma",
- size = 16,
- weight = 600,
- antialias = false,
- shadow = false,
- outline = false,
- }
- tblFonts["j0rpi8"] = {
- font = "Verdana",
- size = 12,
- weight = 100,
- antialias = false,
- shadow = false,
- outline = true,
- }
- tblFonts["j0rpiAA"] = {
- font = "Segoe UI Light",
- size = 19,
- weight = 100,
- antialias = true,
- shadow = false,
- outline = false,
- }
- tblFonts["j0rpiAA2"] = {
- font = "Segoe UI Light",
- size = 18,
- weight = 100,
- antialias = true,
- shadow = false,
- outline = false,
- }
- tblFonts["j0rpiAA3"] = {
- font = "Segoe UI Light",
- size = 24,
- weight = 200,
- antialias = true,
- shadow = true,
- outline = false,
- }
- for k,v in SortedPairs( tblFonts ) do
- surface.CreateFont( k, tblFonts[k] );
- --print( "Added font '"..k.."'" );
- end
- --local function DrawInfo()
- -- local wep = localplayer:GetActiveWeapon()
- -- if IsValid(wep) and GAMEMODE.Config.weaponhud then
- -- local name = wep:GetPrintName();
- -- draw.DrawText("Weapon: "..name, "UiBold", RelativeX + 5, RelativeY - HUDHeight - 18, Color(255, 255, 255, 255), 0)
- -- end
- ----end
- local Page = Material("icon16/application_view_list.png")
- local function GunLicense()
- if localplayer:getDarkRPVar("HasGunlicense") then
- surface.SetMaterial(Page)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(505, ScrH() - 60, 25, 25)
- end
- end
- local WantedIcon = Material( "icon16/exclamation.png" )
- local function DrawWantedIcon()
- if LocalPlayer():getDarkRPVar("wanted") then
- surface["SetMaterial"]( WantedIcon )
- surface["SetDrawColor"]( 255, 255, 255, 255 )
- surface["DrawTexturedRect"]( 505, ScrH() - 92, 23, 23 )
- end
- end
- /*---------------------------------------------------------------------------
- Drawing the HUD elements such as Health etc.
- ---------------------------------------------------------------------------*/
- local playersIcon = Material("icon16/group.png")
- local adminsIcon = Material("icon16/shield.png")
- local name = Material("icon16/user_suit.png")
- local job = Material("icon16/wrench.png")
- local salarr = Material("icon16/money_add.png")
- local banii = Material("icon16/money_dollar.png")
- local played = Material("icon16/time.png")
- local gradient = Material("materials/darkrp/j0rpihpgradient6.png")
- local hpgradient = Material("materials/darkrp/j0rpihpgradient2.png")
- local star = Material("icon16/star.png")
- local heart = Material("icon16/heart.png")
- local heart_add = Material("icon16/heart_add.png")
- local shield = Material("icon16/shield.png")
- local contributor = Material("icon16/add.png")
- local heart = Material("icon16/heart.png")
- local donator = Material("icon16/asterisk_orange.png")
- local smiley = Material("icon16/emoticon_smile.png")
- local developer = Material("icon16/wrench.png")
- local owner = Material("icon16/rosette.png")
- local princess = Material("icon16/user_female.png")
- local vip = Material("icon16/accept.png")
- local mod = Material("icon16/emoticon_grin.png")
- local OwnerIcon = Material("icon16/shield.png")
- local SuperAdminIcon = Material("icon16/shield.png")
- local AdminIcon = Material("icon16/award_star_gold_1.png")
- local ModIcon = Material("icon16/emoticon_grin.png")
- local DevIcon = Material("icon16/wrench.png")
- local TrialModIcon = Material("icon16/emoticon_smile.png")
- local DonatorIcon = Material("icon16/heart.png")
- local RespectedIcon = Material("icon16/heart_add.png")
- local UserIcon = Material("icon16/user.png")
- local ErrorIcon = Material("icon16/error.png")
- local function timeToStr( time )
- local tmp = time
- local s = tmp % 60
- tmp = math.floor( tmp / 60 )
- local m = tmp % 60
- tmp = math.floor( tmp / 60 )
- local h = tmp % 24
- tmp = math.floor( tmp / 24 )
- local d = tmp % 7
- local w = math.floor( tmp / 7 )
- return string.format( "%02i:%02i:%02i", h, m, s )
- end
- local health = 0
- local armour = 0
- surface.CreateFont("RankFont",{font = "akbar", size = 30, weight = 400, antialias = 0})
- local function DrawHUD()
- localplayer = localplayer and IsValid(localplayer) and localplayer or LocalPlayer()
- if not IsValid(localplayer) then return end
- Scrw, Scrh = ScrW(), ScrH()
- RelativeX, RelativeY = 0, Scrh
- local Salary = "Salary: " .. GAMEMODE.Config.currency .. (localplayer:getDarkRPVar("salary") or 0)
- local Job = localplayer:getDarkRPVar("job") or ""
- local Wallet = "Wallet: " .. GAMEMODE.Config.currency .. (formatNumber(localplayer:getDarkRPVar("money") or 0) or 0)
- local lowammo = Color(120,0,0,200)
- if LocalPlayer():Alive() && LocalPlayer():GetActiveWeapon():IsValid() then
- if LocalPlayer():GetActiveWeapon():Clip1() < 0 then
- elseif LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physcannon" or LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physgun" then
- else
- if LocalPlayer():GetActiveWeapon():Clip1() < 6 then
- draw.SimpleText("Press R To Reload!", "j0rpi3", ScrW() - 170, ScrH() - 70, Color(0,0,0,255))
- draw.SimpleText("Press R To Reload!", "j0rpi3", ScrW() - 171, ScrH() - 71, Color(255,0,0,255))
- draw.RoundedBox(0, ScrW() - 200, ScrH() - 50, 180, 45, lowammo)
- surface.SetDrawColor(255,255,255,150)
- surface.DrawOutlinedRect( ScrW() - 200, ScrH() - 50, 180, 45 )
- else
- lowammo = Color(0,0,0,200)
- draw.RoundedBox(0, ScrW() - 200, ScrH() - 50, 180, 45, lowammo)
- surface.SetDrawColor(255,255,255,150)
- surface.DrawOutlinedRect( ScrW() - 200, ScrH() - 50, 180, 45 )
- end
- end
- -- Magazine Size
- if LocalPlayer():GetActiveWeapon():Clip1() < 0 then
- -- Do nada.
- elseif LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physcannon" or LocalPlayer():GetActiveWeapon():GetClass() == "weapon_physgun" then
- -- Do nada.
- else
- draw.SimpleText(LocalPlayer():GetActiveWeapon():Clip1(), "j0rpi", ScrW() - 145, ScrH() - 28, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Ammo Seperator
- draw.SimpleText("|", "j0rpi", ScrW() - 111, ScrH() - 28, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Total Ammo
- draw.SimpleText(LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) or "0", "j0rpi", ScrW() - 74, ScrH() - 28, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- end
- end
- draw.RoundedBox(0, 0 + 10, ScrH() - 94 + 1 - 27 - 8, 240, 25, team.GetColor(LocalPlayer():Team()))
- draw.RoundedBox(0, 0 + 10, ScrH() - 94 + 1 - 27 - 8, 240, 10, Color(255,255,255,20))
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect( 0 + 10, ScrH() - 94 + 1 - 27 - 8, 240, 25 )
- surface.SetMaterial(job)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(0 + 15, ScrH() - 89 + 1 - 27 - 8, 16, 16)
- draw.SimpleText(Job, "j0rpiAA2", 0 + 135, ScrH() - 81 + 1 - 27 - 8, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- session
- draw.RoundedBox(0, 0 + 260, ScrH() - 94 + 1 - 27 - 8, 240, 25, Color(0,0,0,200))
- draw.RoundedBox(0, 0 + 260, ScrH() - 94 + 1 - 27 - 8, 240, 10, Color(255,255,255,10))
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect( 0 + 260, ScrH() - 94 + 1 - 27 - 8, 240, 25 )
- surface.SetMaterial(played)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(0 + 265, ScrH() - 89 + 1 - 27 - 8, 16, 16)
- draw.SimpleText("Session: " .. timeToStr(CurTime()),"j0rpiAA2", 0 + 385, ScrH() - 81 + 1 - 27 - 8, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Wallet
- draw.RoundedBox(0, 0 + 260, ScrH() - 63 + 1 - 27 - 8, 240, 25, Color(0,0,0,200))
- draw.RoundedBox(0, 0 + 260, ScrH() - 63 + 1 - 27 - 8, 240, 10, Color(255,255,255,10))
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect( 0 + 260, ScrH() - 63 + 1 - 27 - 8, 240, 25 )
- surface.SetMaterial(banii)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(0 + 265, ScrH() - 59 + 1 - 27 - 8, 16, 16)
- draw.SimpleText(Wallet, "j0rpiAA2", 0 + 382,ScrH() - 50 + 1 - 27 - 8, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Salary
- draw.RoundedBox(0, 0 + 10, ScrH() - 63 + 1 - 27 - 8, 240, 25, Color(0,0,0,200))
- draw.RoundedBox(0, 0 + 10, ScrH() - 63 + 1 - 27 - 8, 240, 10, Color(255,255,255,10))
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect( 0 + 10, ScrH() - 63 + 1 - 27 - 8, 240, 25 )
- surface.SetMaterial(salarr)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(0 + 15, ScrH() - 59 + 1 - 27 - 8, 16, 16)
- draw.SimpleText(Salary, "j0rpiAA2", 0 + 135,ScrH() - 50 + 1 - 27 - 8, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- --Health = math.min(100, (Health == localplayer:Health() and Health) or Lerp(0.1, Health, localplayer:Health()))
- local drawWidth = 490
- health = Lerp( FrameTime()*2, health,(LocalPlayer():Health()/LocalPlayer():GetMaxHealth())* drawWidth )
- draw.RoundedBox(0, 0 + 10, ScrH() - 32 - 3 - 31, 490, 25, Color(0,0,0,200))
- if health != 0 then
- surface.SetDrawColor(Color(200, 0, 0, 255))
- surface.DrawRect(0 + 10, ScrH() - 32 - 3 - 31, math.Clamp(health,0,drawWidth), 25)
- end
- surface.SetDrawColor(Color(255, 255, 255, 10))
- surface.DrawRect(0 + 10, ScrH() - 32 - 3 - 31, 490, 10)
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect( 0 + 10, ScrH() - 32 - 3 - 31, 490, 25 )
- surface.SetMaterial(heart)
- surface.SetDrawColor(255,255,255,255)
- surface.DrawTexturedRect(0 + 15, RelativeY - 28 - 3 - 31, 16, 16)
- draw.SimpleText("HP: " .. math.Max(0, math.Round(LocalPlayer():Health())).."%","j0rpiAA2", 0 + 255, RelativeY - 19 - 3 - 31, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- --Armor = math.min(100, (Armor == localplayer:Armor() and Armor) or Lerp(0.1, Armor, localplayer:Armor()))
- --local drawWidth = 490
- armour = Lerp( FrameTime()*2, armour,(LocalPlayer():Armor()/100)* drawWidth )
- --Armor = localplayer:Armor()
- --local DrawArmor = math.Min(Armor / 100, 1)
- draw.RoundedBox(0, 0 + 10, ScrH() - 32 - 3, 490, 25, Color(0,0,0,200))
- if armour != 0 then
- surface.SetDrawColor(Color(0, 0, 255, 255))
- surface.DrawRect(0 + 10, ScrH() - 32 - 3, math.Clamp(armour,0, drawWidth), 25)
- end
- surface.SetDrawColor(Color(255, 255, 255, 10))
- surface.DrawRect(0 + 10, ScrH() - 32 - 3, 490, 10)
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect( 0 + 10, ScrH() - 32 - 3, 490, 25 )
- surface.SetMaterial(shield)
- surface.SetDrawColor(255,255,255,255)
- surface.DrawTexturedRect(0 + 15, RelativeY - 28 - 3, 16, 16)
- draw.SimpleText("AP: " .. math.Max(0, math.Round(LocalPlayer():Armor())).."%","j0rpiAA2", 0 + 255, RelativeY - 19 - 3, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Players
- local players = player.GetAll()
- local playerCount = #player.GetAll()
- surface.SetDrawColor(Color(0,0,0,200))
- surface.DrawRect(500 + 11, ScrH() - 35 - 31, 120, 25, Color(0,0,0,200))
- surface.SetDrawColor(Color(255,255,255,10))
- surface.DrawRect(500 + 11, ScrH() - 35 - 31, 120, 10, Color(255,255,255,10))
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect(500 + 11, ScrH() - 35 - 31, 120, 25)
- surface.SetMaterial(playersIcon)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(505 + 11, ScrH() - 31 - 31, 16, 16)
- draw.SimpleText("Players: " .. playerCount, "j0rpiAA2", 570, ScrH() - 22 - 31, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- -- Admins
- local adminCount = 0
- for i, ply in ipairs(players) do
- if not IsValid(ply) then continue end
- if useIsAdminCheck then
- if not ply:IsAdmin() then continue end
- else
- if not adminGroups[ply:GetUserGroup()] then continue end
- end
- adminCount = adminCount + 1
- end
- surface.SetDrawColor(Color(0,0,0,200))
- surface.DrawRect(500 + 11, ScrH() - 35, 120, 25)
- surface.SetDrawColor(Color(255,255,255,10))
- surface.DrawRect(500 + 11, ScrH() - 35, 120, 10)
- surface.SetDrawColor(0,0,0,255)
- surface.DrawOutlinedRect(500 + 11, ScrH() - 35, 120, 25)
- surface.SetMaterial(adminsIcon)
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawTexturedRect(505 + 11, ScrH() - 31, 16, 16)
- draw.SimpleText("Admins: " .. adminCount, "j0rpiAA2", 570, ScrH() - 22, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
- end
- local colors = {}
- colors.black = Color(0, 0, 0, 255)
- colors.blue = Color(0, 0, 255, 255)
- colors.brightred = Color(200, 30, 30, 255)
- colors.darkred = Color(0, 0, 70, 100)
- colors.darkblack = Color(0, 0, 0, 200)
- colors.gray1 = Color(0, 0, 0, 155)
- colors.gray2 = Color(51, 58, 51,100)
- colors.red = Color(255, 0, 0, 255)
- colors.white = Color(255, 255, 255, 255)
- colors.white1 = Color(255, 255, 255, 200)
- /*---------------------------------------------------------------------------
- Entity HUDPaint things
- ----------------------------------------------------------------------------*/
- function DrawPlayerInfo(ply)
- local pos = ply:EyePos()
- pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
- pos = pos:ToScreen()
- if not ply:getDarkRPVar("wanted") then
- -- Move the text up a few pixels to compensate for the height of the text
- pos.y = pos.y - 50
- end
- if GAMEMODE.Config.showname then
- local nick, plyTeam = ply:Nick(), ply:Team()
- draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
- draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
- end
- if GAMEMODE.Config.showhealth then
- local health = DarkRP.getPhrase("health", ply:Health())
- draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x + 1, pos.y + 21, colors.black, 1)
- draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x, pos.y + 20, colors.white1, 1)
- end
- if GAMEMODE.Config.showjob then
- local teamname = ply:getDarkRPVar("job") or team.GetName(ply:Team())
- draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, colors.black, 1)
- draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x, pos.y + 40, colors.white1, 1)
- end
- if self:getDarkRPVar("HasGunlicense") then
- surface.SetMaterial(Page)
- surface.SetDrawColor(255,255,255,255)
- surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
- end
- end
- -- Draw wanted information above a player's head
- -- This syntax allows for easy overriding
- local plyMeta = FindMetaTable("Player")
- plyMeta.drawPlayerInfo = plyMeta.drawPlayerInfo or function(self)
- local pos = self:EyePos()
- pos.z = pos.z + 10 -- The position we want is a bit above the position of the eyes
- pos = pos:ToScreen()
- if not self:getDarkRPVar("wanted") then
- -- Move the text up a few pixels to compensate for the height of the text
- pos.y = pos.y - 50
- end
- if GAMEMODE.Config.showname then
- local nick, plyTeam = self:Nick(), self:Team()
- draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
- draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
- end
- if GAMEMODE.Config.showhealth then
- local health = DarkRP.getPhrase("health", self:Health())
- draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x + 1, pos.y + 21, colors.black, 1)
- draw.DrawNonParsedText(health, "DarkRPHUD2", pos.x, pos.y + 20, colors.white1, 1)
- end
- if GAMEMODE.Config.showjob then
- local teamname = self:getDarkRPVar("job") or team.GetName(self:Team())
- draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x + 1, pos.y + 41, colors.black, 1)
- draw.DrawNonParsedText(teamname, "DarkRPHUD2", pos.x, pos.y + 40, colors.white1, 1)
- end
- if self:getDarkRPVar("HasGunlicense") then
- surface.SetMaterial(Page)
- surface.SetDrawColor(255,255,255,255)
- surface.DrawTexturedRect(pos.x-16, pos.y + 60, 32, 32)
- end
- end
- -- Draw wanted information above a player's head
- -- This syntax allows for easy overriding
- plyMeta.drawWantedInfo = plyMeta.drawWantedInfo or function(self)
- if not self:Alive() then return end
- local pos = self:EyePos()
- if not pos:isInSight({localplayer, self}) then return end
- pos.z = pos.z + 10
- pos = pos:ToScreen()
- if GAMEMODE.Config.showname then
- local nick, plyTeam = self:Nick(), self:Team()
- draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x + 1, pos.y + 1, colors.black, 1)
- draw.DrawNonParsedText(nick, "DarkRPHUD2", pos.x, pos.y, RPExtraTeams[plyTeam] and RPExtraTeams[plyTeam].color or team.GetColor(plyTeam) , 1)
- end
- local wantedText = DarkRP.getPhrase("wanted", tostring(self:getDarkRPVar("wantedReason")))
- draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x, pos.y - 40, colors.white1, 1)
- draw.DrawNonParsedText(wantedText, "DarkRPHUD2", pos.x + 1, pos.y - 41, colors.red, 1)
- end
- /*---------------------------------------------------------------------------
- The Entity display: draw HUD information about entities
- ---------------------------------------------------------------------------*/
- local function DrawEntityDisplay()
- local shouldDraw, players = hook.Call("HUDShouldDraw", GAMEMODE, "DarkRP_EntityDisplay")
- if shouldDraw == false then return end
- local shootPos = localplayer:GetShootPos()
- local aimVec = localplayer:GetAimVector()
- for k, ply in pairs(players or player.GetAll()) do
- if ply == localplayer or not ply:Alive() or ply:GetNoDraw() then continue end
- local hisPos = ply:GetShootPos()
- if ply:getDarkRPVar("wanted") then ply:drawWantedInfo() end
- if GAMEMODE.Config.globalshow then
- ply:drawPlayerInfo()
- -- Draw when you're (almost) looking at him
- elseif hisPos:DistToSqr(shootPos) < 160000 then
- local pos = hisPos - shootPos
- local unitPos = pos:GetNormalized()
- if unitPos:Dot(aimVec) > 0.95 then
- local trace = util.QuickTrace(shootPos, pos, localplayer)
- if trace.Hit and trace.Entity ~= ply then break end
- ply:drawPlayerInfo()
- end
- end
- end
- local tr = localplayer:GetEyeTrace()
- if IsValid(tr.Entity) and tr.Entity:isKeysOwnable() and tr.Entity:GetPos():DistToSqr(localplayer:GetPos()) < 40000 then
- tr.Entity:drawOwnableInfo()
- 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)
- /*---------------------------------------------------------------------------
- Actual HUDPaint hook
- ---------------------------------------------------------------------------*/
- function DisableDrawInfo()
- return false
- end
- hook.Add("HUDDrawTargetID", "DisableDrawInfo", DisableDrawInfo)
- function paintHUD()
- --DrawZombieInfo()
- --self.BaseClass:HUDPaint()
- --DrawWantedIcon()
- --DrawInfo()
- DrawHUD()
- --GunLicense()
- DrawEntityDisplay()
- --Agenda()
- DrawVoiceChat()
- LockDown()
- Arrested()
- AdminTell()
- end
- hook.Add( "HUDPaint", "paintHUD", paintHUD )
- 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), "[ViscaGaming] ", Color(200, 200, 200, 255), txt, "\n")
- end
- usermessage.Hook("_Notify", DisplayNotify)
- local hideHUDElements = {
- ["DarkRP_HUD"] = true,
- ["DarkRP_EntityDisplay"] = false,
- ["DarkRP_ZombieInfo"] = true,
- ["DarkRP_LocalPlayerHUD"] = true,
- ["DarkRP_Hungermod"] = true,
- ["DarkRP_Agenda"] = true,
- }
- /*-- Hide HUD Elements --*/
- local function hideElements(name)
- if name == "CHudHealth" or name == "CHudBattery" or name == "CHudSuitPower" or name == "CHudAmmo" or name == "CHudSecondaryAmmo" then
- return false
- end
- if hideHUDElements[name] then
- return false
- end
- end
- hook.Add("HUDShouldDraw", "hideElements", hideElements)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement