Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 44.46 KB | None | 0 0
  1. PHDayZ = PHDayZ or {}
  2.  
  3. local CurDeathTime = 0
  4.  
  5. net.Receive( "net_DeathMessage", function( len )
  6.    
  7.     DeathMessage = net.ReadString()
  8.     surface.PlaySound( "music/death.wav" )
  9.     DeathMessage2 = ""
  10.     local ply = LocalPlayer()
  11.     if ply.IsVIP and ply:IsVIP() then
  12.         CurDeathTime = (CurTime()+PHDayZ.vipdeathtime)
  13.     else
  14.         CurDeathTime = (CurTime()+PHDayZ.deathtime)
  15.     end
  16.    
  17. end)
  18.  
  19. local blur = Material("pp/blurscreen")
  20. function drawBlurAt(x, y, w, h, amount, passes, reverse)
  21.     -- Intensity of the blur.
  22.     amount = amount or 5
  23.  
  24.     surface.SetMaterial(blur)
  25.     surface.SetDrawColor(255, 255, 255)
  26.  
  27.     local scrW, scrH = ScrW(), ScrH()
  28.     local x2, y2 = x / scrW, y / scrH
  29.     local w2, h2 = (x + w) / scrW, (y + h) / scrH
  30.  
  31.     for i = -(passes or 0.2), 1, 0.2 do
  32.         if reverse then
  33.             blur:SetFloat("$blur", i*-1 * amount)
  34.         else
  35.             blur:SetFloat("$blur", i * amount)
  36.         end
  37.         blur:Recompute()
  38.  
  39.         render.UpdateScreenEffectTexture()
  40.         surface.DrawTexturedRectUV(x, y, w, h, x2, y2, w2, h2)
  41.     end
  42. end
  43.  
  44. function Pulsate(c) --used for flashing colors
  45.     return (math.abs(math.sin(CurTime()*c)))
  46. end
  47.  
  48. function Fluctuate(c) --used for flashing colors
  49.     return (math.cos(CurTime()*c)+1)/2
  50. end
  51.  
  52. net.Receive("PHDayZ_ServerErrors", function( len )
  53.     PHDayZ_CriticalErrors = net.ReadTable()
  54. end)
  55.  
  56. local soundplaying = false
  57. function ShowSZPopup()
  58.     local SW, SH = ScrW(),ScrH()
  59.        
  60.     if LocalPlayer():GetSafeZone() or LocalPlayer():GetSafeZoneEdge() then
  61.         local mcount = LocalPlayer():GetItemAmount("item_money")
  62.         local ccount = LocalPlayer():GetItemAmount("item_credits")
  63.  
  64.         draw.RoundedBox(4,SW/2-150,0,300,40,Color( 0,0, 0, 155 ))              
  65.         draw.DrawText("$"..mcount, "Cyb_HudTEXT", SW/2-100, 8, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)        
  66.         draw.DrawText("XP:"..math.Round(LocalPlayer():GetXP()), "Cyb_HudTEXT", SW/2+100, 8, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)               
  67.         draw.DrawText("¢"..ccount, "Cyb_HudTEXT", SW/2, 8, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)   
  68.     end
  69.  
  70.     local TagTime = LocalPlayer():GetTagTime()
  71.  
  72.     if GUI_CombatMusic == 1 then
  73.         if LocalPlayer():GetTagTime() > CurTime() then
  74.             if !soundplaying then
  75.                 soundplaying = true
  76.                 surface.PlaySound("music/combat3.wav")
  77.                 timer.Simple(60, function() soundplaying = false end)
  78.             end
  79.         end
  80.     end
  81.  
  82.     if IsValid(SZPanel) then   
  83.         if SZPanel.Moving then return end
  84.  
  85.         local DoMove = false
  86.         if LocalPlayer():GetTagTime() < CurTime() and SZPanel.WasTagged then
  87.             DoMove = true
  88.         elseif LocalPlayer():GetSafeZone() and SZPanel.Edge then
  89.             DoMove = true
  90.         elseif LocalPlayer():GetSafeZoneEdge() and !SZPanel.Edge then
  91.             DoMove = true
  92.         elseif ( !LocalPlayer():GetSafeZone() and !LocalPlayer():GetSafeZoneEdge() ) or ( LocalPlayer():GetTagTime() > CurTime() and !SZPanel.WasTagged ) then
  93.             DoMove = true
  94.         elseif GUI_ShowSZHint != 1 then
  95.             DoMove = true
  96.         end
  97.  
  98.         if DoMove then
  99.             SZPanel:MoveTo(ScrW(), 200, 1, 0.1, -1, function(anim, pnl)
  100.                 SZPanel:Remove()
  101.             end)
  102.             SZPanel.Moving = true
  103.         end
  104.  
  105.     end
  106.  
  107.     if ( !LocalPlayer():GetSafeZone() and !LocalPlayer():GetSafeZoneEdge() ) or IsValid(SZPanel) then return end
  108.     if GUI_ShowSZHint != 1 then return end
  109.  
  110.     SZPanel = vgui.Create("DPanel")
  111.     SZPanel:SetSize(200, 55)
  112.     SZPanel:SetPos(ScrW(), 200)
  113.     SZPanel.Edge = LocalPlayer():GetSafeZoneEdge()
  114.     SZPanel.WasTagged = ( LocalPlayer():GetTagTime() > CurTime() )
  115.  
  116.     local text = (LocalPlayer():GetSafeZone() and LANG.GetTranslation("safezone")) or (LocalPlayer():GetSafeZoneEdge() and LANG.GetTranslation("safezoneedge")) or ""
  117.     local infotext = ( LocalPlayer():GetTagTime() > CurTime() ) and "Vulnerable to Damage" or (LocalPlayer():GetSafeZone() and LANG.GetTranslation("safezonehint")) or (LocalPlayer():GetSafeZoneEdge() and LANG.GetTranslation("safezonehint")) or LANG.GetTranslation("safezonevuln")
  118.     local color = Color(255, 255, 255, 255)
  119.  
  120.     if ( LocalPlayer():GetTagTime() > CurTime() ) then
  121.         color = Color(255, 0, 0, 255)
  122.     end
  123.  
  124.     SZPanel.Paint = function(self, w, h)
  125.  
  126.         local szcountdown = ""
  127.         if self.WasTagged then
  128.             szcountdown = " ("..math.Round(LocalPlayer():GetTagTime() - CurTime()).."s)"
  129.             if math.Round(LocalPlayer():GetTagTime() - CurTime()) <= 0 then
  130.                 szcountdown = ""
  131.             end
  132.         end
  133.  
  134.         draw.RoundedBox(4, 0, 0, w, h, Color(10, 10, 10, 200))
  135.         draw.DrawText(text, "char_title24", w/2, 8, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
  136.         draw.DrawText(infotext..szcountdown, "char_title16", w/2, 28, color, TEXT_ALIGN_CENTER)
  137.  
  138.     end
  139.  
  140.     SZPanel:MoveTo(ScrW()-200, 200, 1, 0.1, -1, function() if IsValid(SZPanel) then SZPanel.Moving = false end end)
  141.  
  142.     --timer.Simple(10, function() if IsValid(SZPanel) then SZPanel:Remove() end end)
  143.  
  144. end
  145.  
  146. PHDayZ_CriticalErrors = PHDayZ_CriticalErrors or {}
  147.  
  148. local function ShowSetupErrors()
  149.     if #PHDayZ_CriticalErrors < 1 then return end
  150.     local w = ScrW()
  151.     local h = 200
  152.     local padding = ScrW()/2-w/2
  153.  
  154.  
  155.     local y = ScrH()/2
  156.     local color = Color(Pulsate(1)*255, 0, 0, 255)
  157.  
  158.     draw.RoundedBoxEx(4, padding-1, y-h/2, w, h, Color(10, 10, 10, 200), false, false, false, false)
  159.     draw.SimpleTextOutlined( "THIS SERVER HAS CRITICAL GAMEMODE SETUP ERRORS (SEE ERROR FAQ)", "SafeZone_NAME", padding + w/2 - 4, y-60, color, 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  160.  
  161.     local i = 0
  162.     for k, v in pairs(PHDayZ_CriticalErrors) do
  163.         draw.SimpleTextOutlined( v, "tab_title", padding + w/2 - 4, y+i, Color(255,0,0,255), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  164.         i = i + 30
  165.     end
  166.    
  167. end
  168.  
  169. local CssContent = false
  170. local Hl2EP2Content = false
  171. local DayZContent = false
  172. local function CheckMissingContent()
  173.  
  174.     if !CssContent then
  175.         if IsMounted('cstrike') then CssContent = true elseif file.Exists("models/props/de_piranesi/pi_sundial.mdl", "GAME") then CssContent = true end
  176.     end
  177.  
  178.     if !Hl2EP2Content then
  179.         if IsMounted('ep2') then Hl2EP2Content = true elseif file.Exists("models/antlion_worker.mdl", "GAME") then Hl2EP2Content = true end
  180.     end
  181.  
  182.     if !DayZContent then
  183.         if file.Exists("models/zed/malezed_04.mdl", "GAME") then DayZContent = true end
  184.     end
  185.  
  186.     if CssContent and Hl2EP2Content and DayZContent then timer.Destroy("ContentChecker") end
  187.  
  188. end
  189. timer.Create("ContentChecker", 5, 0, CheckMissingContent)
  190.  
  191. local function ShowMissingContent()
  192.     --if #PHDayZ_MissingContent < 1 then return end
  193.     --if IsMounted('ep2') then return end
  194.     if GUI_ShowMissingContent == 0 then return end
  195.  
  196.     if CssContent and Hl2EP2Content and DayZContent then return end
  197.  
  198.     local w = 538
  199.     local h = 170
  200.     local padding = 0
  201.     local tpad = 20
  202.     local y = 175
  203.     local color = Color( 140, 50, 50, 255 )
  204.    
  205.     draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, Color(10, 10, 10, 150), false, true, false, true)
  206.      
  207.     draw.SimpleTextOutlined( "YOUR CLIENT IS MISSING CONTENT!", "SafeZone_NAME", padding + w/2, y-70, Color( 255, 0, 0, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  208.  
  209.     if !CssContent then
  210.         draw.SimpleTextOutlined( "Content: 'CSS' not found!", "Cyb_HudTEXT", tpad, y-40, Color( 255, 255, 255, 255 ), 0, 1, 0.5, Color( 0, 0, 0, 255 ))
  211.     end
  212.  
  213.     if !Hl2EP2Content then
  214.         draw.SimpleTextOutlined( "Content: 'HL2:Episode 2' not found!", "Cyb_HudTEXT", tpad, y-20, Color( 255, 255, 255, 255 ), 0, 1, 0.5, Color( 0, 0, 0, 255 ))
  215.     end
  216.  
  217.     if !DayZContent then
  218.         draw.SimpleTextOutlined( "Content: 'GMod DayZ' not found!", "Cyb_HudTEXT", tpad, y, Color( 255, 255, 255, 255 ), 0, 1, 0.5, Color( 0, 0, 0, 255 ))
  219.     end
  220.  
  221.     draw.SimpleTextOutlined( "ENJOY ERRORS/MISSING TEXTURES!", "SafeZone_NAME", padding + w/2, y+40, Color( 255, 0, 0, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  222.     draw.SimpleTextOutlined( "No, seriously. Get the content from gmoddayz.net", "Cyb_HudTEXT", tpad, y+70, Color( 255, 255, 255, 255 ), 0, 1, 0.5, Color( 0, 0, 0, 255 ))
  223. end
  224.  
  225. local function GetHungerValue()
  226.     return math.Clamp(LocalPlayer():GetHunger(), 0, 1000)
  227. end
  228.  
  229. local function GetThirstValue()
  230.     return math.Clamp(LocalPlayer():GetThirst(), 0, 1000)
  231. end
  232.  
  233. net.Receive("net_DeathMessage2", function( len )
  234.     DeathMessage2 = "Any key to continue..."
  235. end)
  236.  
  237. function GM:DrawDeathNotice(x, y)
  238.     return
  239. end
  240.  
  241. function HideThings( name )
  242.     if (name == "CHudDamageIndicator" ) then
  243.         return false
  244.     end
  245. end
  246. hook.Add( "HUDShouldDraw", "HideThings", HideThings )
  247.  
  248. function GM:HUDShouldDraw(Name)
  249.     if IsValid(LocalPlayer()) and LocalPlayer():GetSafeZone() && Name == "CHudWeaponSelection" then
  250.         return false
  251.     end
  252.     return true
  253. end
  254.  
  255. local grad = Material("gui/gradient")
  256. local tagmat = Material("gui/icon_cyb_64_red.png")
  257. local edgemat = Material("gui/icon_cyb_64_orange.png")
  258. local safemat = Material("gui/icon_cyb_64_blue.png")
  259.  
  260. ProcessName = ProcessName or "N/A"
  261. ProcessTime = ProcessTime or 0
  262. ProcessItem = ProcessItem or ""
  263. ProcessRunning = ProcessRunning or false
  264. local ProcessStartTime = RealTime()
  265. function DoProcessBar()
  266.     ProcessName = net.ReadString()
  267.     ProcessAmount = net.ReadInt(16)
  268.     ProcessTime = net.ReadFloat()
  269.     ProcessItem = net.ReadString()
  270.  
  271.     ProcessItem = ProcessItem or "item_wood"
  272.  
  273.     ProcessRunning = true
  274.     ProcessStartTime = RealTime()
  275.     MakeProcessBar()
  276. end
  277. net.Receive("DoProcessBar", DoProcessBar)
  278.  
  279. function MakeProcessBar()
  280.     if !ProcessRunning then return end
  281.  
  282.     local name, amount, item, time = ProcessName, ProcessAmount, ProcessItem, ProcessTime
  283.  
  284.     local NewPanel = false
  285.     if !IsValid(ProcessFrame) then
  286.         NewPanel = true
  287.         ProcessFrame = vgui.Create("DPanel")
  288.     end
  289.  
  290.     timer.Create("removeprocessbar", time + 3, 1, function()
  291.         if IsValid(ProcessFrame) then
  292.             ProcessFrame:MoveTo( ScrW()/2 - 250, -85, 0.5, 0, -1, function() if !ProcessFrame.Moving then ProcessFrame:Remove() end end )
  293.         end
  294.     end)
  295.  
  296.     local makecustomicon = false
  297.     if !GAMEMODE.DayZ_Items[item] then
  298.         ProcessFrame.Status = name
  299.         makecustomicon = true
  300.     else
  301.         ProcessFrame.Status = name.." "..GAMEMODE.DayZ_Items[item].Name.." x"..amount
  302.     end
  303.  
  304.     ProcessFrame:SetSize( 500, 85 )
  305.  
  306.     if NewPanel then
  307.         ProcessFrame:SetPos( ScrW()/2 - 250, -85 )
  308.         ProcessFrame.WantsMove = true
  309.     end
  310.  
  311.     ProcessFrame:MoveTo( ScrW()/2 - 250, 60, 0.5, 0, -1, function() ProcessFrame.Moving = false end )
  312.     ProcessFrame.Moving = true
  313.  
  314.     ProcessFrame.Paint = function(self, w, h)
  315.         draw.RoundedBox(4, 0, 0, w, h, Color( 0, 0, 0, 150 ))
  316.  
  317.         draw.RoundedBoxEx(4,5,5,75,75,Color( 0, 0, 0, 50 ), true, true, true, true)
  318.         draw.RoundedBoxEx(4,6,6,75-2,75-2,Color( 255, 255, 255, 10 ), true, true, true, true)
  319.         draw.RoundedBoxEx(4,7,7,75-4,75-4,Color( 60, 60, 60, 255 ), true, true, true, true)
  320.  
  321.         if LocalPlayer():GetItemAmount(item) > 0 then
  322.             draw.DrawText( "x"..LocalPlayer():GetItemAmount(item), "Cyb_Inv_Label", 75, 65, Color(200, 200, 200, 255), TEXT_ALIGN_RIGHT )
  323.         end
  324.  
  325.     end
  326.  
  327.     if IsValid(ProcessFrame.ProcessIconPanel) then -- Remove and re-create.
  328.         ProcessFrame.ProcessIconPanel:Remove()
  329.     end
  330.  
  331.     if makecustomicon then
  332.         ProcessFrame.ProcessIconPanel = vgui.Create("DPanel", ProcessFrame)
  333.         ProcessFrame.ProcessIconPanel.Paint = function(self, w, h)
  334.  
  335.             draw.RoundedBoxEx(4,0,0,w,h,Color( 0, 0, 0, 50 ), true, true, true, true)
  336.             draw.RoundedBoxEx(4,1,1,w-2,h-2,Color( 255, 255, 255, 10 ), true, true, true, true)
  337.             draw.RoundedBoxEx(4,2,2,w-4,h-4,Color( 60, 60, 60, 255 ), true, true, true, true)
  338.  
  339.         end
  340.         ProcessFrame.ProcessIconPanel:SetSize(75, 75)
  341.  
  342.         ProcessFrame.ProcessIcon = vgui.Create("DModelPanel", ProcessFrame.ProcessIconPanel)
  343.         ProcessFrame.ProcessIcon:SetPos(0, 0)
  344.         ProcessFrame.ProcessIcon:SetSize(80, 80)
  345.         ProcessFrame.ProcessIcon:SetModel( item )
  346.        
  347.         local PaintModel = ProcessFrame.ProcessIcon.Paint
  348.         ProcessFrame.ProcessIcon.LayoutEntity = function() end
  349.         ProcessFrame.ProcessIcon:SetDrawOnTop(false)
  350.  
  351.         local mn, mx = ProcessFrame.ProcessIcon:GetEntity():GetRenderBounds();
  352.         local size = 0;
  353.         size = math.max(size, math.abs(mn.x) + math.abs(mx.x));
  354.         size = math.max(size, math.abs(mn.y) + math.abs(mx.y));
  355.         size = math.max(size, math.abs(mn.z) + math.abs(mx.z));
  356.  
  357.         ProcessFrame.ProcessIcon:SetFOV(45);
  358.         ProcessFrame.ProcessIcon:SetCamPos(Vector(size, size, size));
  359.         ProcessFrame.ProcessIcon:SetLookAt((mn + mx) * 0.5);
  360.         --ProcessFrame.ProcessIcon:GetEntity():SetAngles( Angle(0,0,0) )
  361.  
  362.         function ProcessFrame.ProcessIcon:Paint(w, h)
  363.        
  364.             local x2, y2 = self:GetParent():LocalToScreen( 0, 0 )
  365.             local w2, h2 = self:GetParent():GetSize()
  366.             render.SetScissorRect( x2, y2, x2 + w2, y2 + h2, true )
  367.  
  368.             PaintModel( self, w, h )
  369.            
  370.             render.SetScissorRect( 0, 0, 0, 0, false )
  371.         end
  372.  
  373.     else
  374.  
  375.         ProcessFrame.ProcessIconPanel, ProcessFrame.ProcessIcon = DZ_MakeIcon( item, 0, ProcessFrame, nil, nil, 75, 75, false, true, false )
  376.  
  377.     end
  378.  
  379.     ProcessFrame.ProcessIconPanel:SetPos(5, 5)
  380.  
  381.     if !IsValid(ProcessFrame.ProcessBar) then
  382.         ProcessFrame.ProcessBar = vgui.Create("DPanel", ProcessFrame)
  383.     end
  384.     ProcessFrame.ProcessBar:SetSize( 400, 25 )
  385.     ProcessFrame.ProcessBar:SetPos( 90, 30 )
  386.  
  387.     local width = 0
  388.     local curtime = RealTime() + time
  389.  
  390.     ProcessFrame.ProcessBar.Paint = function(self, w, h)
  391.         draw.RoundedBox(0, 0, 0, w, h, Color( 50, 50, 50, 255 ))
  392.  
  393.         if ProcessRunning and width < 401 then
  394.             if time < 1 then
  395.                 width = ( ( RealTime() - ProcessStartTime ) * (time*4) ) * 400
  396.             else
  397.                 width = ( ( RealTime() - ProcessStartTime ) / time ) * 400
  398.             end
  399.  
  400.             local timeleft = math.Round( curtime - RealTime() )
  401.             if !GAMEMODE.DayZ_Items[item] then
  402.                 ProcessFrame.Status = name.." ( ".. timeleft .."s )"
  403.             else
  404.                 ProcessFrame.Status = name.." "..GAMEMODE.DayZ_Items[item].Name.." x"..amount.." ( ".. timeleft .."s )"
  405.             end
  406.  
  407.         end
  408.  
  409.         surface.SetDrawColor( 30, 30, 30, 150 )
  410.         surface.DrawRect( 0, 0, width, h )
  411.  
  412.         if width >= 400 then
  413.             ProcessFrame.Status = "Finished!"
  414.         end
  415.  
  416.         draw.DrawText( ProcessFrame.Status, "Cyb_Inv_Label", w/2, h-18, Color(200,200,200,255), TEXT_ALIGN_CENTER )
  417.     end
  418. end
  419.  
  420. local red, green = 255, 0
  421. --Stop progress bar
  422. function StopProcessBar()
  423.     ProcessRunning = false
  424.  
  425.     if IsValid(ProcessFrame) then
  426.         ProcessFrame.Status = "Cancelled!"
  427.         timer.Simple(3, function()
  428.             if IsValid(ProcessFrame) then
  429.                 ProcessFrame:MoveTo( ScrW()/2 - 250, -85, 0.5, 0, -1, function() if !ProcessFrame.Moving then ProcessFrame:Remove() end end )
  430.             end
  431.         end)
  432.     end
  433.  
  434.     red, green = 255, 0
  435. end
  436. net.Receive("StopProcessBar", StopProcessBar)
  437.  
  438. local function DrawProcessBar()
  439.     if ProcessRunning then
  440.         local wid = ScrW() / 3
  441.         local hei = ScrH() / 30
  442.         surface.SetDrawColor( 30, 30, 30, 150 )
  443.         surface.DrawRect( ScrW() * 0.5 - wid * 0.5, ScrH() / 30, wid, hei )
  444.  
  445.         local width = ( ( RealTime() - ProcessStartTime ) / ProcessTime ) * wid
  446.         if width >= wid then UpdateAllTabs() StopProcessBar() return end -- end
  447.         surface.SetDrawColor( red, green, 0, 255)
  448.         red = 255/(width/150)
  449.         green = (width/3)
  450.         surface.DrawRect( ScrW() * 0.5 - wid * 0.5, ScrH() / 30, width, hei )
  451.  
  452.         surface.SetDrawColor( 27, 167, 219,255 )
  453.         surface.DrawOutlinedRect( ScrW() * 0.5 - wid * 0.5, ScrH() / 30, wid, hei )
  454.  
  455.         draw.SimpleText( ProcessName, "Cyb_HudTEXT", ScrW() * 0.5, hei * 1.5, Color( 255, 255, 255, 255 ), 1, 1 )
  456.     end
  457. end
  458.  
  459. function hidehud(name)
  460.     for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo"})do
  461.         if name == v then return false end
  462.     end
  463. end
  464. hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)
  465.  
  466. local ButtonMaterial = Material("cyb_mat/cyb_keybut.png")
  467. local ButtonPanel
  468. function GM:HUDDrawTargetID()
  469.     local tr = LocalPlayer():GetEyeTrace()
  470.  
  471.     hook.Call("DZ_HudTargetID", GAMEMODE, tr)
  472.        
  473.     if IsValid(tr.Entity) and (tr.Entity:GetClass() == "prop_physics") and (tr.Entity:Health() > 0) then
  474.         if PHDayZ.AllowPropDamage then
  475.             local ent = tr.Entity
  476.             local maxhp, hp, pos = ent:GetMaxHealth(), ent:Health(), ent:GetPos()
  477.             local percentCalc = 255 * (hp / maxhp)
  478.             draw.SimpleTextOutlined(tostring(hp) .." / " ..tostring(maxhp), "TargetIDSmall", ScrW()/2, ScrH()/2-50, Color(255-percentCalc,percentCalc,0,255), 1, 1, 1, Color(0,0,0,255))
  479.         end
  480.     end
  481.  
  482.     if IsValid(tr.Entity) and tr.Entity:GetClass() == "base_item" and LocalPlayer():GetPos():Distance(tr.Entity:GetPos()) < 100 then
  483.         local class = tr.Entity:GetItem()
  484.  
  485.         local tab = { tr.Entity }
  486.         halo.Add( tab, Color( 255, 255, 255 ), 5, 5, 2 )
  487.  
  488.         if LocalPlayer():KeyDown(IN_USE) then
  489.             if IsValid(ButtonPanel) then return end
  490.  
  491.             ButtonPanel = vgui.Create("DPanel")
  492.             ButtonPanel.Paint = function(self, w, h)
  493.                 draw.RoundedBox( 4, 0, 0, w, h, Color(0,0,0,220) )
  494.             end
  495.             local i = 0
  496.  
  497.             if GAMEMODE.DayZ_Items[class].CanIgnite and LocalPlayer():HasItem("item_firestarter") and !tr.Entity:IsOnFire() then
  498.                 ButtonPanel.Ignite = vgui.Create("DButton", ButtonPanel)
  499.                 ButtonPanel.Ignite:Dock(TOP)
  500.                 ButtonPanel.Ignite:SetTall(15)
  501.                 ButtonPanel.Ignite:SetText("")
  502.                 ButtonPanel.Ignite.Paint = function(self, w, h)
  503.                     local boxcolor = Color(0,0,0,255)
  504.                     local textcolor = Color(255,255,255,255)
  505.                     if self:IsHovered() then
  506.                         boxcolor = Color(255,255,255,255)
  507.                         textcolor = Color(0,0,0,255)
  508.                     end
  509.  
  510.                     draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  511.  
  512.                     draw.DrawText( "Set on Fire", "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  513.                 end
  514.                 ButtonPanel.Ignite.DoClick = function(self)
  515.                     net.Start("base_ItemAction")
  516.                         net.WriteUInt(4, 4)
  517.                         net.WriteUInt(tr.Entity:EntIndex() , 32)
  518.                     net.SendToServer()
  519.                 end
  520.                 i = i + 15
  521.             end
  522.  
  523.             if GAMEMODE.DayZ_Items[class].Weapon or GAMEMODE.DayZ_Items[class].Body or GAMEMODE.DayZ_Items[class].Pants or GAMEMODE.DayZ_Items[class].Shoes or GAMEMODE.DayZ_Items[class].BackPack or GAMEMODE.DayZ_Items[class].Hat then
  524.                 ButtonPanel.Equip = vgui.Create("DButton", ButtonPanel)
  525.                 ButtonPanel.Equip:Dock(TOP)
  526.                 ButtonPanel.Equip:SetTall(15)
  527.                 ButtonPanel.Equip:SetText("")
  528.                 ButtonPanel.Equip.Paint = function(self, w, h)
  529.                     local boxcolor = Color(0,0,0,255)
  530.                     local textcolor = Color(255,255,255,255)
  531.                     if self:IsHovered() then
  532.                         boxcolor = Color(255,255,255,255)
  533.                         textcolor = Color(0,0,0,255)
  534.                     end
  535.  
  536.                     draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  537.  
  538.                     draw.DrawText( "Equip", "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  539.                 end
  540.                 ButtonPanel.Equip.DoClick = function(self)
  541.                     net.Start("base_ItemAction")
  542.                         net.WriteUInt(5, 4)
  543.                         net.WriteUInt(tr.Entity:EntIndex(), 32)
  544.                     net.SendToServer()
  545.                 end
  546.                 i = i + 15
  547.             end
  548.  
  549.             if GAMEMODE.DayZ_Items[class].CustomFunc and GAMEMODE.DayZ_Items[class].CustomFuncName then
  550.                 ButtonPanel.CustomFunc = vgui.Create("DButton", ButtonPanel)
  551.                 ButtonPanel.CustomFunc:Dock(TOP)
  552.                 ButtonPanel.CustomFunc:SetTall(15)
  553.                 ButtonPanel.CustomFunc:SetText("")
  554.                 ButtonPanel.CustomFunc.Paint = function(self, w, h)
  555.                     local boxcolor = Color(0,0,0,255)
  556.                     local textcolor = Color(255,255,255,255)
  557.                     if self:IsHovered() then
  558.                         boxcolor = Color(255,255,255,255)
  559.                         textcolor = Color(0,0,0,255)
  560.                     end
  561.  
  562.                     draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  563.  
  564.                     draw.DrawText( GAMEMODE.DayZ_Items[class].CustomFuncName, "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  565.                 end
  566.                 ButtonPanel.CustomFunc.DoClick = function(self)
  567.                     net.Start("base_ItemAction")
  568.                         net.WriteUInt(3, 4)
  569.                         net.WriteUInt(tr.Entity:EntIndex() , 32)
  570.                     net.SendToServer()
  571.                 end
  572.                 i = i + 15
  573.             end
  574.  
  575.             if GAMEMODE.DayZ_Items[class].Function and !GAMEMODE.DayZ_Items[class].NoConsumeFromFloor then
  576.                 ButtonPanel.Consume = vgui.Create("DButton", ButtonPanel)
  577.                 ButtonPanel.Consume:Dock(TOP)
  578.                 ButtonPanel.Consume:SetTall(15)
  579.                 ButtonPanel.Consume:SetText("")
  580.                 ButtonPanel.Consume.Paint = function(self, w, h)
  581.                     local boxcolor = Color(0,0,0,255)
  582.                     local textcolor = Color(255,255,255,255)
  583.                     if self:IsHovered() then
  584.                         boxcolor = Color(255,255,255,255)
  585.                         textcolor = Color(0,0,0,255)
  586.                     end
  587.  
  588.                     draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  589.  
  590.                     draw.DrawText( "Use", "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  591.                 end
  592.                 ButtonPanel.Consume.DoClick = function(self)
  593.                     net.Start("base_ItemAction")
  594.                         net.WriteUInt(1, 4)
  595.                         net.WriteUInt(tr.Entity:EntIndex() , 32)
  596.                         net.WriteUInt(3, 4)
  597.                     net.SendToServer()
  598.                 end
  599.                 i = i + 15
  600.             end
  601.  
  602.             if GAMEMODE.DayZ_Items[class].EatFunction and !GAMEMODE.DayZ_Items[class].NoConsumeFromFloor then
  603.                 ButtonPanel.Consume = vgui.Create("DButton", ButtonPanel)
  604.                 ButtonPanel.Consume:Dock(TOP)
  605.                 ButtonPanel.Consume:SetTall(15)
  606.                 ButtonPanel.Consume:SetText("")
  607.                 ButtonPanel.Consume.Paint = function(self, w, h)
  608.                     local boxcolor = Color(0,0,0,255)
  609.                     local textcolor = Color(255,255,255,255)
  610.                     if self:IsHovered() then
  611.                         boxcolor = Color(255,255,255,255)
  612.                         textcolor = Color(0,0,0,255)
  613.                     end
  614.  
  615.                     draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  616.  
  617.                     draw.DrawText( "Eat", "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  618.                 end
  619.                 ButtonPanel.Consume.DoClick = function(self)
  620.                     net.Start("base_ItemAction")
  621.                         net.WriteUInt(1, 4)
  622.                         net.WriteUInt(tr.Entity:EntIndex() , 32)
  623.                         net.WriteUInt(1, 4)
  624.                     net.SendToServer()
  625.                 end
  626.                 i = i + 15
  627.             end
  628.  
  629.             if GAMEMODE.DayZ_Items[class].DrinkFunction and !GAMEMODE.DayZ_Items[class].NoConsumeFromFloor then
  630.                 ButtonPanel.Consume = vgui.Create("DButton", ButtonPanel)
  631.                 ButtonPanel.Consume:Dock(TOP)
  632.                 ButtonPanel.Consume:SetTall(15)
  633.                 ButtonPanel.Consume:SetText("")
  634.                 ButtonPanel.Consume.Paint = function(self, w, h)
  635.                     local boxcolor = Color(0,0,0,255)
  636.                     local textcolor = Color(255,255,255,255)
  637.                     if self:IsHovered() then
  638.                         boxcolor = Color(255,255,255,255)
  639.                         textcolor = Color(0,0,0,255)
  640.                     end
  641.  
  642.                     draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  643.  
  644.                     draw.DrawText( "Drink", "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  645.                 end
  646.                 ButtonPanel.Consume.DoClick = function(self)
  647.                     net.Start("base_ItemAction")
  648.                         net.WriteUInt(1, 4)
  649.                         net.WriteUInt(tr.Entity:EntIndex() , 32)
  650.                         net.WriteUInt(2, 4)
  651.                     net.SendToServer()
  652.                 end
  653.                 i = i + 15
  654.             end
  655.  
  656.             ButtonPanel.Collect = vgui.Create("DButton", ButtonPanel)
  657.             ButtonPanel.Collect:Dock(TOP)
  658.             ButtonPanel.Collect:SetTall(15)
  659.             ButtonPanel.Collect:SetText("")
  660.             ButtonPanel.Collect.Paint = function(self, w, h)
  661.                 local boxcolor = Color(0,0,0,255)
  662.                 local textcolor = Color(255,255,255,255)
  663.                 if self:IsHovered() then
  664.                     boxcolor = Color(255,255,255,255)
  665.                     textcolor = Color(0,0,0,255)
  666.                 end
  667.  
  668.                 draw.RoundedBox( 0, 0, 0, w, h, boxcolor )
  669.  
  670.                 draw.DrawText( "Collect", "Cyb_Inv_Label", w/2, 0, textcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  671.             end
  672.             ButtonPanel.Collect.DoClick = function(self)
  673.                 net.Start("base_ItemAction")
  674.                     net.WriteUInt(2, 4)
  675.                     net.WriteUInt(tr.Entity:EntIndex() , 32)
  676.                 net.SendToServer()
  677.             end
  678.             i = i + 15
  679.  
  680.             gui.EnableScreenClicker(true)
  681.  
  682.             ButtonPanel:SetPos((ScrW()/2)-75, (ScrH()/2)-(i/2) )
  683.             ButtonPanel:SetSize(150, i)
  684.  
  685.             return
  686.         end
  687.         if IsValid(ButtonPanel) then ButtonPanel:Remove() gui.EnableScreenClicker(false) end
  688.  
  689.         local color = Color(200,200,200,255)
  690.         surface.SetFont("Cyb_Inv_Label")
  691.         local sizex, sizey = surface.GetTextSize(" - "..GAMEMODE.DayZ_Items[class].Desc)
  692.         sizex = sizex+10
  693.  
  694.         if sizex < 130 then sizex = 130 end
  695.  
  696.         local x = ScrW()/2-(sizex/2)+5
  697.         local y = ScrH()/2-55
  698.         local perish = "Perishes in "..math.Round( tr.Entity:GetPerish() + 1 - CurTime() ).." seconds"
  699.  
  700.         draw.RoundedBox( 4, (ScrW()/2)-(sizex/2), (ScrH()/2)-60, sizex, 120, Color(0,0,0,220) )
  701.         draw.DrawText( GAMEMODE.DayZ_Items[class].Name.." x"..tr.Entity:GetAmount(), "Cyb_Inv_Label", x, y, color, TEXT_ALIGN_LEFT )
  702.         draw.DrawText( " - "..GAMEMODE.DayZ_Items[class].Desc, "Cyb_Inv_Label", x, y+15, color, TEXT_ALIGN_LEFT )
  703.         draw.DrawText( "Condition: "..GetCondition(tr.Entity:GetCondition()), "Cyb_Inv_Label", x, y+50, color, TEXT_ALIGN_LEFT ) -- Conditions on the way...
  704.         draw.DrawText( "Weight: "..GAMEMODE.DayZ_Items[class].Weight, "Cyb_Inv_Label", x, y+85, color, TEXT_ALIGN_LEFT )
  705.         draw.DrawText( perish, "Cyb_Inv_Label", x, y+100, color, TEXT_ALIGN_LEFT )
  706.     else
  707.         if IsValid(ButtonPanel) then ButtonPanel:Remove() gui.EnableScreenClicker(false) end
  708.     end
  709.    
  710.     if tr.Entity:IsPlayer() then
  711.         if tr.Entity:GetMoveType() != MOVETYPE_NOCLIP and tr.Entity:Alive() then
  712.             local TrgPos = tr.Entity:GetPos()+Vector(0,0,64)
  713.             local ScrPos = (TrgPos + Vector( 0, 0, 10 )):ToScreen()
  714.             local Distance = TrgPos:Distance( LocalPlayer():GetPos() )
  715.             local Nick = tr.Entity:Nick()  
  716.             local GroupName = team.GetName(tr.Entity:Team()) or ""
  717.             surface.SetFont("Cyb_HudTEXT")
  718.             local Nickx, Nicky = surface.GetTextSize(Nick)
  719.             Nickx = Nickx + 20
  720.             if Nickx < 150 then Nickx = 200 end
  721.  
  722.             local BoxSize = 60
  723.             local FreshPos = 25
  724.             local FreshSpawn = false
  725.  
  726.             if GroupName != "" then
  727.                 BoxSize = BoxSize + 30
  728.                 FreshPos = FreshPos + 25
  729.             end
  730.  
  731.             if tr.Entity:GetFreshSpawn() then
  732.                 FreshSpawn = true
  733.                 BoxSize = BoxSize + 30
  734.             end
  735.  
  736.             local TheGroupColor = team.GetColor(tr.Entity:Team()) or Color(255, 255, 255, alp)
  737.            
  738.             if Distance < PHDayZ.NamedDistance then
  739.                 local alp =  255 * (math.abs((Distance-PHDayZ.NamedDistance))/600)
  740.                 TheGroupColor.a = alp
  741.                 draw.RoundedBox( 4, ScrPos.x-(Nickx/2), ScrPos.y-30, Nickx, BoxSize, Color( 0, 0, 0, alp ) )
  742.                 draw.DrawText(Nick, "Cyb_HudTEXT", ScrPos.x, ScrPos.y-20, Color(255, 255, 255, alp),TEXT_ALIGN_CENTER)             
  743.                 if tr.Entity:Frags() >= PHDayZ.killstobebounty then
  744.                     draw.DrawText("[BOUNTY]", "Cyb_Inv_Bar", ScrPos.x, ScrPos.y+5, Color(255, 0, 0, alp),TEXT_ALIGN_CENTER)
  745.                 elseif tr.Entity:Frags() >= PHDayZ.killstobebandit then
  746.                     draw.DrawText("[BANDIT]", "Cyb_Inv_Bar", ScrPos.x, ScrPos.y+5, Color(200, 0, 0, alp),TEXT_ALIGN_CENTER)
  747.                 elseif tr.Entity:GetNWBool("friendly") == true and tr.Entity:Frags() < PHDayZ.killstobebandit then
  748.                     draw.DrawText("[HERO]", "Cyb_Inv_Bar", ScrPos.x, ScrPos.y+5, Color(0, 255, 0, alp),TEXT_ALIGN_CENTER)                  
  749.                 else
  750.                     draw.DrawText("[UNKNOWN]", "Cyb_Inv_Bar", ScrPos.x, ScrPos.y+5, Color(255, 255, 255, alp),TEXT_ALIGN_CENTER)   
  751.                 end
  752.  
  753.                 draw.DrawText(GroupName, "Cyb_HudTEXT", ScrPos.x, ScrPos.y+25, TheGroupColor,TEXT_ALIGN_CENTER)
  754.  
  755.                 if FreshSpawn then
  756.                     draw.DrawText("[Fresh Spawn]", "Cyb_HudTEXT", ScrPos.x, ScrPos.y+FreshPos, Color(255,255,0),TEXT_ALIGN_CENTER)
  757.                 end
  758.             end
  759.         end
  760.     end
  761. end
  762.  
  763. local DMGIndicatorAlpha = 0
  764. local function ReceieveHurtInfo()
  765.     local TimeH = 0.5
  766.     LocalPlayer().DmgIndicatorTime = CurTime() + TimeH
  767.     DMGIndicatorAlpha = 100
  768. end
  769.  
  770. net.Receive("HurtInfo", function(len)
  771.     ReceieveHurtInfo()
  772. end)
  773.  
  774. hook.Add("HUDPaint", "DrawDamageIndicator", function()
  775.     if DMGIndicatorAlpha <= 0 then return end
  776.    
  777.     if LocalPlayer().DmgIndicatorTime and LocalPlayer().DmgIndicatorTime < CurTime() then
  778.         DMGIndicatorAlpha = DMGIndicatorAlpha - FrameTime() * 600
  779.     end
  780.    
  781.     if DMGIndicatorAlpha > 0 then
  782.         draw.RoundedBox( 0, 0, 0, ScrW(), ScrH(), Color( 255, 0, 0, DMGIndicatorAlpha ) )  
  783.     end
  784. end)
  785.  
  786. local HitIndicatorAlpha = 0
  787.    
  788. local function SendHitInfo()
  789.     local Time = 0.5
  790.     LocalPlayer().HitIndicatorTime = CurTime() + Time
  791.     HitIndicatorAlpha = 255
  792. end
  793. net.Receive("SendHitInfo", function(len)
  794.     SendHitInfo()
  795. end)
  796.    
  797. hook.Add("HUDPaint", "DrawHitIndicator", function()
  798.     if HitIndicatorAlpha <= 0 then return end
  799.     if LocalPlayer().HitIndicatorTime and LocalPlayer().HitIndicatorTime < CurTime() then
  800.         HitIndicatorAlpha = HitIndicatorAlpha - FrameTime() * 600
  801.     end
  802.        
  803.     if HitIndicatorAlpha > 0 then
  804.            
  805.         local x = ScrW() / 2
  806.         local y = ScrH() / 2
  807.              
  808.         local Lenght = 21 * (HitIndicatorAlpha / 255)
  809.         Lenght = math.Clamp(Lenght, 8, Lenght)
  810.         local Size = 7
  811.            
  812.         surface.SetDrawColor( 0, 0, 0, HitIndicatorAlpha )
  813.            
  814.         surface.DrawLine( x + Size, y - Size, x + Lenght, y - Lenght )
  815.         surface.DrawLine( x - Size, y + Size, x -Lenght, y + Lenght )
  816.            
  817.         surface.DrawLine( x + Size, y + Size, x + Lenght, y + Lenght )
  818.         surface.DrawLine( x - Size, y - Size, x - Lenght, y - Lenght )
  819.            
  820.         surface.SetDrawColor( 225, 225, 225, HitIndicatorAlpha )
  821.         Lenght = 20 * (HitIndicatorAlpha / 255)
  822.         Lenght = math.Clamp(Lenght, 8, Lenght)
  823.         Size = 8
  824.            
  825.         surface.DrawLine( x + Size, y - Size, x + Lenght, y - Lenght )
  826.         surface.DrawLine( x - Size, y + Size, x - Lenght, y + Lenght )
  827.            
  828.         surface.DrawLine( x + Size, y + Size, x + Lenght, y + Lenght )
  829.         surface.DrawLine( x - Size, y - Size, x - Lenght, y - Lenght )
  830.            
  831.     end
  832.    
  833. end)
  834.  
  835. local healthmat = Material("cyb_mat/cyb_health.png", "smooth")
  836. local healthsmooth = 0
  837. local function DrawHealth()
  838.  
  839.     local w = 48
  840.     local h = 48
  841.     local padding = 133
  842.  
  843.     healthsmooth = math.Approach( healthsmooth, LocalPlayer():GetRealHealth(), 50 * FrameTime() )
  844.     local percent = healthsmooth / 100
  845.  
  846.     local y = ScrH() - 175
  847.     local color = Color( 140, 50, 50, 255 )
  848.     if LocalPlayer():GetSick() or (LocalPlayer():GetRealHealth() < 25) then
  849.         color = Color(Pulsate(1)*140, 50, 50, 255)
  850.     end
  851.    
  852.     draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, Color(10, 10, 10, 150), false, true, false, true)
  853.    
  854.     render.SetMaterial( healthmat )
  855.     render.DrawQuadEasy( Vector( padding + w/2, y),
  856.         Vector(0,0,-1),
  857.         w, h,
  858.         Color( 10, 10, 40, 240 ),
  859.         -90
  860.     )
  861.  
  862.     render.SetScissorRect( 0, y+h/2 - (h * percent), padding + w, ScrH(), true )
  863.     render.SetMaterial( healthmat )
  864.     render.DrawQuadEasy( Vector( padding + w/2, y),
  865.         Vector(0,0,-1),
  866.         w, h,
  867.         color,
  868.         -90
  869.     )
  870.     render.SetScissorRect( 0, y+h/2, padding + w, ScrH(), false )
  871.  
  872.     if GUI_ShowHUDLabels > 0 then
  873.         draw.SimpleTextOutlined( math.Round(percent*100), "Cyb_HudTEXTSmall", padding + w/2, y, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  874.     end
  875.  
  876. end
  877.  
  878. local function GetVehicleFuelValue()
  879.     local vehicle = LocalPlayer():GetVehicle()
  880.     if !IsValid(vehicle) then return false end
  881.    
  882.     if IsValid(vehicle:GetParent()) then vehicle = vehicle:GetParent() end
  883.     if !vehicle.GetFuel then return false end
  884.  
  885.     return math.Round(vehicle:GetFuel())
  886. end
  887.  
  888. local vehfuelmat = Material("gui/icon_cyb_64_fuel.png", "smooth")
  889. local function DrawVehicleFuel()
  890.     if !GetVehicleFuelValue() then return end
  891.     local w = 48
  892.     local h = 48
  893.     local padding = 15
  894.     local percent = GetVehicleFuelValue() / 100
  895.     local y = ScrH() - 285
  896.     local color = Color( 255, 100, 0, 255 )
  897.     if GetVehicleFuelValue() < 25 then
  898.         color = Color(255, Pulsate(1)*100, 0, 255)
  899.     end
  900.    
  901.     local boxcolor = Color(10, 10, 10, 150)
  902.    
  903.     draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)
  904.    
  905.     render.SetMaterial( vehfuelmat )
  906.     render.DrawQuadEasy( Vector( padding + w/2, y),
  907.         Vector(0,0,-1),
  908.         w, h,
  909.         Color( 10, 10, 40, 240 ),
  910.         -90
  911.     )
  912.  
  913.     render.SetScissorRect( 0, y+h/2 - (h * percent), padding + w, ScrH(), true )
  914.     render.DrawQuadEasy( Vector( padding + w/2, y),
  915.         Vector(0,0,-1),
  916.         w, h,
  917.         color,
  918.         -90
  919.     )
  920.     render.SetScissorRect( 0, y+h/2, padding + w, ScrH(), false )
  921.  
  922.     if GUI_ShowHUDLabels > 0 then
  923.         draw.SimpleTextOutlined( GetVehicleFuelValue(), "Cyb_HudTEXTSmall", padding + w/2, y, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  924.     end
  925.    
  926. end
  927.  
  928. local function GetVehicleHealthValue()
  929.     local vehicle = LocalPlayer():GetVehicle()
  930.     if !IsValid(vehicle) then return false end
  931.    
  932.     if IsValid(vehicle:GetParent()) then vehicle = vehicle:GetParent() end
  933.    
  934.     return math.Round(vehicle:Health())
  935. end
  936.  
  937. local function GetVehicleHealthValue()
  938.     local vehicle = LocalPlayer():GetVehicle()
  939.     if !IsValid(vehicle) then return false end
  940.    
  941.     if IsValid(vehicle:GetParent()) then vehicle = vehicle:GetParent() end
  942.     local maxhealth = vehicle:GetMaxHealth()
  943.     if maxhealth == 0 then maxhealth = 100 end
  944.    
  945.     return (vehicle:Health() / maxhealth)
  946. end
  947.  
  948. local vehhealthmat = Material("gui/icon_cyb_64_spanner.png", "smooth")
  949. local function DrawVehicleHealth()
  950.     if !GetVehicleHealthValue() then return end
  951.     local w = 48
  952.     local h = 48
  953.     local padding = 75
  954.     local percent = math.Round(GetVehicleHealthValue() * 100)
  955.     local y = ScrH() - 285
  956.     local color = Color( 0, 175, 63, 255 )
  957.     if percent < 25 then
  958.         color = Color(Pulsate(1)*255, 175, 63, 255)
  959.     end
  960.    
  961.     local boxcolor = Color(10, 10, 10, 150)
  962.    
  963.     draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)
  964.    
  965.     render.SetMaterial( vehhealthmat )
  966.     render.DrawQuadEasy( Vector( padding + w/2, y),
  967.         Vector(0,0,-1),
  968.         w, h,
  969.         Color( 10, 10, 40, 240 ),
  970.         -90
  971.     )
  972.  
  973.     render.SetScissorRect( 0, y+h/2 - (h * percent/100), padding + w, ScrH(), true )
  974.     render.DrawQuadEasy( Vector( padding + w/2, y),
  975.         Vector(0,0,-1),
  976.         w, h,
  977.         color,
  978.         -90
  979.     )
  980.     render.SetScissorRect( 0, y+h/2, padding + w, ScrH(), false )
  981.  
  982.     if GUI_ShowHUDLabels > 0 then
  983.         draw.SimpleTextOutlined( percent.."%", "Cyb_HudTEXTSmall", padding + w/2, y, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  984.     end
  985.    
  986. end
  987.  
  988. local thirstmat = Material("cyb_mat/cyb_thirst.png", "smooth")
  989. local thirstsmooth = 0
  990. local function DrawThirst()
  991.     if !GetThirstValue() then return end
  992.  
  993.     local w = 48
  994.     local h = 48
  995.     local padding = 133
  996.  
  997.     thirstsmooth = math.Approach( thirstsmooth, GetThirstValue(), 50 * FrameTime() )
  998.     local percent = thirstsmooth / 1000
  999.  
  1000.     local y = ScrH() - 105
  1001.     local color = Color( 50, 50, 200, 255 )
  1002.     if GetThirstValue() < 25 then
  1003.         color = Color(50, 50, Pulsate(1)*200, 255)
  1004.     end
  1005.    
  1006.     local boxcolor = Color(10, 10, 10, 150)
  1007.     if ( LocalPlayer():GetSafeZone() or LocalPlayer():GetSafeZoneEdge() ) and PHDayZ.NoSafezoneDrain then
  1008.         boxcolor = Color(150, 150, 150, 50)
  1009.     end
  1010.    
  1011.     draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, false, true, false, true)
  1012.    
  1013.     render.SetMaterial( thirstmat )
  1014.     render.DrawQuadEasy( Vector( padding + w/2, y),
  1015.         Vector(0,0,-1),
  1016.         w, h,
  1017.         Color( 10, 10, 40, 240 ),
  1018.         -90
  1019.     )
  1020.  
  1021.     render.SetScissorRect( 0, y+h/2 - (h * percent), padding + w, ScrH(), true )
  1022.     render.DrawQuadEasy( Vector( padding + w/2, y),
  1023.         Vector(0,0,-1),
  1024.         w, h,
  1025.         color,
  1026.         -90
  1027.     )
  1028.     render.SetScissorRect( 0, y+h/2, padding + w, ScrH(), false )
  1029.  
  1030.     if GUI_ShowHUDLabels > 0 then
  1031.         draw.SimpleTextOutlined( math.Round(percent*1000), "Cyb_HudTEXTSmall", padding + w/2, y, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  1032.     end
  1033. end
  1034.  
  1035. local hungermat = Material("cyb_mat/cyb_hunger.png", "smooth")
  1036. local hungersmooth = 0
  1037. local function DrawHunger()
  1038.     if !GetHungerValue() then return end
  1039.  
  1040.     local w = 48
  1041.     local h = 48
  1042.     local padding = 133
  1043.  
  1044.     hungersmooth = math.Approach( hungersmooth, GetHungerValue(), 50 * FrameTime() )
  1045.     local percent = hungersmooth / 1000
  1046.  
  1047.     local y = ScrH() - 35
  1048.     local color = Color( 50, 200, 50, 255 )
  1049.     if GetHungerValue() < 25 then
  1050.         color = Color(50, Pulsate(1)*200, 50, 255)
  1051.     end
  1052.    
  1053.     local boxcolor = Color(10, 10, 10, 150)
  1054.     if ( LocalPlayer():GetSafeZone() or LocalPlayer():GetSafeZoneEdge() ) and PHDayZ.NoSafezoneDrain then
  1055.         boxcolor = Color(150, 150, 150, 50)
  1056.     end
  1057.    
  1058.     draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, false, true, false, true)
  1059.        
  1060.     render.SetMaterial( hungermat )
  1061.     render.DrawQuadEasy( Vector( padding + w/2, y),
  1062.         Vector(0,0,-1),
  1063.         w, h,
  1064.         Color( 10, 10, 40, 240 ),
  1065.         -90
  1066.     )
  1067.  
  1068.     render.SetScissorRect( 0, y+h/2 - (h * percent), padding + w, ScrH(), true )
  1069.     render.SetMaterial( hungermat )
  1070.     render.DrawQuadEasy( Vector( padding + w/2, y),
  1071.         Vector(0,0,-1),
  1072.         w, h,
  1073.         color,
  1074.         -90
  1075.     )
  1076.     render.SetScissorRect( 0, y+h/2, padding + w, ScrH(), false )
  1077.  
  1078.     if GUI_ShowHUDLabels > 0 then
  1079.         draw.SimpleTextOutlined( math.Round(percent*1000), "Cyb_HudTEXTSmall", padding + w/2, y, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  1080.     end
  1081. end
  1082.  
  1083. local hp_bg = Material( "cyb_mat/cyb_hpbg.png", "smooth" )
  1084. local bloodsmooth = 0
  1085. local function DrawBlood()
  1086.     if !LocalPlayer():Health() then return end
  1087.  
  1088.     local w = 94
  1089.     local h = 242
  1090.     local padding = 23
  1091.     bloodsmooth = math.Approach( bloodsmooth, LocalPlayer():Health(), 50 * FrameTime() )
  1092.  
  1093.     local percent = bloodsmooth / LocalPlayer():GetMaxHealth()
  1094.  
  1095.     local y = ScrH() - (10 * 3) - (20 * 3)
  1096.     local color = Color( 140, 50, 50, 255 )
  1097.     if LocalPlayer():GetBleed() or (LocalPlayer():Health() <= 20) then
  1098.         color = Color(Pulsate(1)*140, 50, 50, 255)
  1099.     end
  1100.     draw.RoundedBoxEx(4, padding-1, y-h/2, w, h, Color(10, 10, 10, 150), false, false, false, false)
  1101.  
  1102.     render.SetMaterial( hp_bg )
  1103.     render.DrawQuadEasy( Vector( padding + w/2, ScrH() - h/2,0),
  1104.         Vector(0,0,-1),
  1105.         w, h,
  1106.         Color( 40, 10, 10, 240 ),
  1107.         -90
  1108.     )
  1109.  
  1110.     render.SetScissorRect( 0, ScrH() - (h * percent), padding + w, ScrH(), true )
  1111.     render.SetMaterial( hp_bg )
  1112.     render.DrawQuadEasy( Vector( padding + w/2, ScrH() - h/2,0),
  1113.         Vector(0,0,-1),
  1114.         w, h,
  1115.         color,
  1116.         -90
  1117.     )
  1118.     render.SetScissorRect( 0, ScrH() - h + 20, padding + w, ScrH(), false )
  1119.  
  1120.     if GUI_ShowHUDLabels > 0 then
  1121.         draw.SimpleTextOutlined( ""..math.Round(percent*100)/20 .. " L", "Cyb_HudTEXTSmall", padding + w/2 - 4, ScrH() - h/2 - 26, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))
  1122.     end
  1123.    
  1124. end
  1125.  
  1126. local function DrawXP()
  1127.  
  1128.     local padding = 0
  1129.     local w = 12
  1130.     local h = 211
  1131.     local bgc = Color( 10, 10, 10, 150 )
  1132.     local inc = Color( 30, 30, 30, 200 )
  1133.     local plyxp = LocalPlayer():GetXP() or 0
  1134.     LocalPlayer().CL_Level = LocalPlayer():GetLevel() or 1
  1135.     XPBarLength = plyxp/(PHDayZ.XPLevelMultiplier * LocalPlayer().CL_Level)
  1136.    
  1137.     local offset = 10
  1138.     local percent = plyxp/(PHDayZ.XPLevelMultiplier * LocalPlayer().CL_Level)
  1139.     local y = math.Round( h * percent )
  1140.  
  1141.     draw.RoundedBoxEx(4, offset + padding, ScrH() - padding - h, w, h, Color(10, 10, 10, 150), true, false, true, false)
  1142.  
  1143.     draw.RoundedBoxEx(4, offset + padding, ScrH() - padding - y, w, h, Color(50, 120, 50, 255), true, true, true, true)
  1144.    
  1145.     if GUI_ShowHUDLabels > 0 then
  1146.         draw.SimpleTextOutlined( LocalPlayer().CL_Level, "Cyb_HudTEXTSmall", offset + padding + w/2, ScrH() - 10, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))   
  1147.     end
  1148. end
  1149.  
  1150. local staminasmooth = 0
  1151. local function DrawStamina()
  1152.  
  1153.     local padding = 13
  1154.     local w = 12
  1155.     local h = 211
  1156.     local bgc = Color( 10, 10, 10, 150 )
  1157.     local inc = Color( 30, 30, 30, 200 )
  1158.     local plystamina = LocalPlayer():GetStamina() or 100
  1159.    
  1160.     staminasmooth = math.Approach( staminasmooth, plystamina*10, 50 * FrameTime() )
  1161.  
  1162.     local offset = 103
  1163.     local percent = staminasmooth / 1000
  1164.     local y = h * percent
  1165.  
  1166.     draw.RoundedBoxEx(4, offset + padding, ScrH() - h, w, h, Color(10, 10, 10, 150), false, true, false, true)
  1167.  
  1168.     draw.RoundedBoxEx(4, offset + padding, ScrH() - y, w, h, Color(120, 120, 50, 255), true, true, false, true)
  1169.  
  1170.     if GUI_ShowHUDLabels > 0 then
  1171.         draw.SimpleTextOutlined( plystamina, "Cyb_HudTEXTSmall", offset + padding + w/2, ScrH() - 10, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 0, 0, 0, 255 ))   
  1172.     end
  1173. end
  1174.  
  1175. local radsmooth = 0
  1176. local function DrawStatusEffects()
  1177.     local w = 48
  1178.     local h = 48
  1179.     local padding = 203
  1180.     local y = ScrH() - 35
  1181.     local color = Color( 255, 100, 0, 255 )
  1182.     local boxcolor = Color(10, 10, 10, 150)
  1183.  
  1184.     if LocalPlayer():GetSick() or healthsmooth < 50 then
  1185.         drawBlurAt( 0, 0, ScrW(), ScrH(), (50-healthsmooth)/4, nil, true )
  1186.         draw.RoundedBox( 0, 0, 0, ScrW(), ScrH(), Color(20, 0, 0, math.Clamp( 255-(healthsmooth*5), 0, 150 ) ) )
  1187.     end
  1188.  
  1189.     if bloodsmooth < 50 then
  1190.         drawBlurAt( 0, 0, ScrW(), ScrH(), (50-bloodsmooth)/4, nil, true )
  1191.         draw.RoundedBox( 0, 0, 0, ScrW(), ScrH(), Color(50, 50, 50, math.Clamp( 255-(bloodsmooth*5), 0, 150 ) ) )
  1192.     end
  1193.  
  1194.     radsmooth = math.Approach( radsmooth, LocalPlayer():GetRadiation(), 50 * FrameTime() )
  1195.  
  1196.     if radsmooth > 50 then
  1197.         util.ScreenShake( Vector( 0, 0, 0 ), 0.3, 5, 1, 0 )
  1198.         draw.RoundedBox( 0, 0, 0, ScrW(), ScrH(), Color(0, 40, 0, math.Clamp( radsmooth*2, 0, 150 ) ) )
  1199.     end
  1200.  
  1201.     if LocalPlayer():GetFreshSpawn() then
  1202.         draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)
  1203.  
  1204.         render.SetMaterial( hp_bg )
  1205.         render.DrawQuadEasy( Vector( padding + w/2, y,0),
  1206.             Vector(0,0,-1),
  1207.             w-22, h,
  1208.             Color( Pulsate(0.5)*40, Pulsate(0.5)*40, Pulsate(0.5)*10, 240 ),
  1209.             -90
  1210.         )
  1211.  
  1212.         AnyStatus = true
  1213.  
  1214.         padding = padding + 70
  1215.     end
  1216.  
  1217.  
  1218.     if LocalPlayer():GetTagTime() > CurTime() then
  1219.         draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)     
  1220.         render.SetMaterial( hp_bg )
  1221.         render.DrawQuadEasy( Vector( padding + w/2, y,0),
  1222.             Vector(0,0,-1),
  1223.             w-22, h,
  1224.             Color( Pulsate(0.5)*40, Pulsate(0.5)*10, Pulsate(0.5)*10, 240 ),
  1225.             -90
  1226.         )
  1227.  
  1228.         AnyStatus = true
  1229.        
  1230.         padding = padding + 70
  1231.     end
  1232.  
  1233.     if GetHungerValue() < 250 then
  1234.         draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)     
  1235.         render.SetMaterial( hungermat )
  1236.         render.DrawQuadEasy( Vector( padding + w/2, y,0),
  1237.             Vector(0,0,-1),
  1238.             w, h,
  1239.             Color( Pulsate(0.5)*10, Pulsate(0.5)*80, Pulsate(0.5)*10, 240 ),
  1240.             -90
  1241.         )
  1242.  
  1243.         AnyStatus = true
  1244.        
  1245.         padding = padding + 70
  1246.     end
  1247.  
  1248.     if GetThirstValue() < 250 then
  1249.         draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)     
  1250.         render.SetMaterial( thirstmat )
  1251.         render.DrawQuadEasy( Vector( padding + w/2, y,0),
  1252.             Vector(0,0,-1),
  1253.             w, h,
  1254.             Color( Pulsate(0.5)*10, Pulsate(0.5)*10, Pulsate(0.5)*80, 240 ),
  1255.             -90
  1256.         )
  1257.  
  1258.         AnyStatus = true
  1259.        
  1260.         padding = padding + 70
  1261.     end
  1262.  
  1263.     if LocalPlayer():GetBleed() then
  1264.         draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)     
  1265.         render.SetMaterial( thirstmat )
  1266.         render.DrawQuadEasy( Vector( padding + w/2, y,0),
  1267.             Vector(0,0,-1),
  1268.             w, h,
  1269.             Color( Pulsate(0.5)*40, Pulsate(0.5)*10, Pulsate(0.5)*10, 240 ),
  1270.             -90
  1271.         )
  1272.  
  1273.         AnyStatus = true
  1274.        
  1275.         padding = padding + 70
  1276.     end
  1277.  
  1278.     if LocalPlayer():GetSick() then
  1279.         draw.RoundedBoxEx(4, padding-5, y-h/2-5, w+10, h+10, boxcolor, true, true, true, true)
  1280.         render.SetMaterial( healthmat )
  1281.         render.DrawQuadEasy( Vector( padding + w/2, y,0),
  1282.             Vector(0,0,-1),
  1283.             w, h,
  1284.             Color( Pulsate(0.5)*10, Pulsate(0.5)*40, Pulsate(0.5)*10, 240 ),
  1285.             -90
  1286.         )
  1287.  
  1288.         AnyStatus = true
  1289.  
  1290.         padding = padding + 70
  1291.     end
  1292.  
  1293. end
  1294.  
  1295. function GM:HUDPaint( )
  1296.     if (GUI_ShowHUD == 0) or DZ_MENUBLUR or !AliveChar then ShowSetupErrors() DZ_LoadingScreen() return end
  1297.    
  1298.     local SW,SH = ScrW(),ScrH()
  1299.    
  1300.     DZ_LoadingScreen()
  1301.  
  1302.     if LocalPlayer():Alive() then
  1303.         DrawStatusEffects()
  1304.  
  1305.         DrawBlood()
  1306.         DrawHealth()
  1307.         DrawThirst()
  1308.         DrawHunger()       
  1309.         DrawStamina()
  1310.         DrawXP()
  1311.        
  1312.         --DrawProcessBar()
  1313.        
  1314.         WSWITCH:Draw(LocalPlayer())
  1315.        
  1316.         DrawVehicleFuel()
  1317.         DrawVehicleHealth()
  1318.  
  1319.         ShowSetupErrors()
  1320.         ShowSZPopup()
  1321.         ShowMissingContent()
  1322.  
  1323.         GAMEMODE:HUDDrawTargetID()
  1324.     else
  1325.         if !DeathMessage then return end
  1326.            
  1327.         local deathcountdown = math.Round(CurDeathTime - CurTime())
  1328.         if deathcountdown <= 0 then
  1329.             deathcountdown = 0
  1330.         end
  1331.        
  1332.         local DeadBoxW = ScrW()
  1333.         local DeadBoxH = 150
  1334.        
  1335.         draw.RoundedBox(0,SW/2-(DeadBoxW/2),SH/2-(DeadBoxH/2),DeadBoxW,DeadBoxH,Color( 0,0, 0, 200 ))
  1336.                
  1337.         draw.DrawText("YOU DIED", "char_title", SW/2, SH/2-50, Color(255, 0, 0, 255),TEXT_ALIGN_CENTER)                                    
  1338.         draw.DrawText(DeathMessage, "char_options1", SW/2, SH/2, Color(150, 150, 150, 255),TEXT_ALIGN_CENTER)  
  1339.         if DeathMessage2 != "" then
  1340.             draw.DrawText(DeathMessage2, "char_options1", SW/2, SH/2+30, Color(150, 150, 150, 255),TEXT_ALIGN_CENTER)  
  1341.             return
  1342.         end
  1343.  
  1344.         draw.DrawText(deathcountdown.." seconds til respawn!", "char_options1", SW/2, SH/2+30, Color(150, 150, 150, 255),TEXT_ALIGN_CENTER)
  1345.        
  1346.     end
  1347.            
  1348.     local intAmmoInMag = 0
  1349.     local intAmmoOutMag = 0
  1350.     if LocalPlayer():GetActiveWeapon():IsValid() and LocalPlayer():GetActiveWeapon():IsWeapon() then
  1351.         intAmmoInMag = LocalPlayer():GetActiveWeapon():Clip1()
  1352.         intAmmoOutMag = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType())
  1353.     end
  1354.                
  1355.     if !WSWITCH.Show and LocalPlayer():GetActiveWeapon():IsValid() && LocalPlayer():GetActiveWeapon():Clip1() >= 0 && LocalPlayer():GetActiveWeapon():GetClass() != "weapon_physcannon" then
  1356.         --draw.RoundedBox(10,SW - 201,SH -81,151,72,Color( 50, 50, 50, 255 ))
  1357.        
  1358.         draw.RoundedBox(6,SW - 200,SH -70,250,100,Color( 0, 0, 0, 200 )) -- Small Ammo Box
  1359.        
  1360.         surface.SetDrawColor(255,255,255,255)
  1361.        
  1362.         surface.SetTextColor(Color(255,255,255))
  1363.         surface.SetFont("AmmoType1")
  1364.         local x,y = surface.GetTextSize( intAmmoInMag )
  1365.         surface.SetTextPos(SW-140-x/2,SH-35-y/2)
  1366.         surface.DrawText( intAmmoInMag )
  1367.        
  1368.         surface.SetTextColor(Color(150,0,0))
  1369.         surface.SetFont("AmmoType2")
  1370.         local x,y = surface.GetTextSize( intAmmoOutMag )
  1371.         surface.SetTextPos(SW-90-x/2,SH-25-y/2)
  1372.         surface.DrawText( "x "..intAmmoOutMag )
  1373.     end    
  1374.  
  1375. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement