Advertisement
GohoCraft

crapy-hud

Apr 4th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.37 KB | None | 0 0
  1. /*#################################################
  2. ###     cl_hud.lua
  3. #################################################*/
  4.  
  5.  
  6. surface.CreateFont( "DefaultSmall", {
  7.     font = "Tahoma",
  8.     size = ScreenScale( 7 ),
  9.     weight = 500
  10. } )
  11.  
  12. surface.CreateFont( "DefaultHealth", {
  13.     font = "Tahoma",
  14.     size = ScreenScale( ScrH()/34 ),
  15.     weight = 900
  16. } )
  17.  
  18. surface.CreateFont( "DefaultArmor", {
  19.     font = "Tahoma",
  20.     size = ScreenScale( 30 ),
  21.     weight = 900
  22. } )
  23.  
  24. surface.CreateFont( "DefaultAmmo", {
  25.     font = "Tahoma",
  26.     size = ScreenScale( 6 ),
  27.     weight = 500
  28. } )
  29.  
  30. surface.CreateFont( "DefaultWeapon", {
  31.     font = "Tahoma",
  32.     size = ScreenScale( 5 ),
  33.     weight = 300
  34. } )
  35.  
  36. function TestDrawHud()
  37.  
  38. local struc = {}
  39. struc.pos = {}
  40. struc.pos[1] = ScrW()*.5 -- x pos
  41. --struc.pos[2] = ScrH()*.005 -- y pos
  42. struc.pos[2] = ScrH()-10 -- y pos
  43. struc.color = Color(0,0,0,255)
  44. struc.text = "--- Baswars PreAlpha v0.1 for GMOD13 by .delay ---"
  45. struc.font = "DefaultFixed" -- Font
  46. struc.xalign = TEXT_ALIGN_CENTER -- Horizontal Alignment
  47. struc.yalign = TEXT_ALIGN_CENTER -- Vertical Alignment
  48. draw.Text( struc )
  49.  
  50. end
  51. hook.Add("HUDPaint", "HUD_TEST", TestDrawHud)
  52.  
  53. function GM:DrawBasewarsHUD()
  54.     local w = ScrW() / 12
  55.     local h = ScrW() / 22
  56.     local x = 5
  57.     local y = ScrH() - h - 5
  58.  
  59.     local w_bar = ScrW() / 8
  60.     local h_bar = ScrW() / 80
  61.     local x_bar = x + w + 5
  62.     local bar_spacing = ScrW() / 300
  63.  
  64.     surface.SetDrawColor( BasewarsBackgroundColor )
  65.     surface.DrawRect( x, y, w, h )
  66.  
  67.     surface.SetDrawColor( BasewarsBorderColor )
  68.     surface.DrawOutlinedRect( x, y, w, h )
  69.     -- Health
  70.     local hpColor = BasewarsTextColor
  71.     if ( LocalPlayer():Health() < 25 ) then hpColor = BasewarsHealthColor end
  72.     draw.SimpleTextOutlined( tostring( LocalPlayer():Health() ), "DefaultHealth", x + w / 2, y + h / 2, hpColor, 1, 1, 0.5, BasewarsBorderColor )
  73.     -- Armor
  74.     local amrColor = BasewarsTextColor
  75.     local bar_y = y + h / 2 - h_bar / 2 - h_bar - bar_spacing
  76.     if ( LocalPlayer():Armor() < 25 ) then hpColor = BasewarsHealthColor end
  77.    
  78.     -- Health & Armor Bars    
  79.     local bar_y = y + h / 2 - h_bar / 2
  80.     local amr_w = math.floor( ( LocalPlayer():Armor() / 100 ) * w_bar )
  81.     surface.SetDrawColor( BasewarsBackgroundColor )
  82.     surface.DrawRect( x_bar, bar_y, w_bar, h_bar )
  83.  
  84.     surface.SetDrawColor( BasewarsArmorColor )
  85.     surface.DrawRect( x_bar, bar_y, amr_w, h_bar )
  86.  
  87.     surface.SetDrawColor( BasewarsBorderColor )
  88.     surface.DrawOutlinedRect( x_bar, bar_y, w_bar, h_bar )
  89.  
  90.     draw.SimpleTextOutlined( "Armor: "..tostring( LocalPlayer():Armor() ).."%", "DefaultSmall", x_bar + w_bar / 2, bar_y + h_bar / 2, BasewarsTextColor, 1, 1, 0.5, BasewarsTextShadowColor )
  91.  
  92.     local bar_y = y + h / 2 - h_bar / 2 + h_bar + bar_spacing
  93.     local health_w = math.floor( ( LocalPlayer():Health() / 100 ) * w_bar )
  94.    
  95.     surface.SetDrawColor( BasewarsBackgroundColor )
  96.     surface.DrawRect( x_bar, bar_y, w_bar, h_bar )
  97.  
  98.     surface.SetDrawColor( BasewarsHealthColor )
  99.     surface.DrawRect( x_bar, bar_y, health_w, h_bar )
  100.  
  101.     surface.SetDrawColor( BasewarsBorderColor )
  102.     surface.DrawOutlinedRect( x_bar, bar_y, w_bar, h_bar )
  103.  
  104.     draw.SimpleTextOutlined( "Health", "DefaultSmall", x_bar + w_bar / 2, bar_y + h_bar / 2, BasewarsTextColor, 1, 1, 0.5, BasewarsTextShadowColor )
  105.  
  106.     -- Ammo Bars
  107.    
  108.     -- This prevents client crash on death. LOL
  109.     -- Dont draw weapon hud if the players wears no valid sweap
  110.     if !LocalPlayer():GetActiveWeapon():IsValid() then return true end
  111.  
  112.     local mag_left = LocalPlayer():GetActiveWeapon():Clip1()
  113.     local mag_extra = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType())
  114.    
  115.     local secondary_ammo = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType())
  116.    
  117.    
  118.     /*
  119.     MaxAmmo={}
  120.     MaxAmmo["weapon_crowbar"]=0
  121.     MaxAmmo["weapon_physcannon"]=0
  122.     MaxAmmo["weapon_physgun"]=0
  123.     MaxAmmo["weapon_pistol"]=18
  124.     MaxAmmo["weapon_357"]=6
  125.     MaxAmmo["weapon_smg1"]=45
  126.     MaxAmmo["weapon_ar2"]=30
  127.     MaxAmmo["weapon_crossbow"]=1
  128.     MaxAmmo["weapon_frag"]=-1
  129.     MaxAmmo["weapon_rpg"]=-1
  130.    
  131.     MaxAmmo["chair_launcher"]=-1
  132.     MaxAmmo["weapon_basewars"]=200
  133.     */
  134.    
  135.    
  136.     local x_ammo_box = ScrW()-230
  137.     local y_ammo_box = ScrH()-60
  138.     local y_ammo_box_s = ScrH()-105
  139.    
  140.     local x_ammo_small = ScrW()-220
  141.     local y_ammo_small = ScrH()-35
  142.     local y_ammo_small_s = ScrH()-80
  143.     local y_ammo_text = ScrH()-55
  144.     local y_ammo_text_s = ScrH()-100
  145.    
  146.     local w_ammo_bars = 200
  147.     local h_ammo_bars = 40
  148.    
  149.     if mag_left <= 0 && mag_extra <= 0 then
  150.         hasprim=0
  151.     else
  152.         hasprim=1
  153.     end
  154.    
  155.     if secondary_ammo <= 0 then
  156.         hassec=0
  157.     else
  158.         hassec=1
  159.     end
  160.     -- Draw ammo box
  161.     /*
  162.     -- Check for maxclipsize
  163.     if(LocalPlayer():GetActiveWeapon().Primary)then
  164.         ammobar=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
  165.         mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
  166.     -- Do other stuff if we cant find the table
  167.     else
  168.         if MaxAmmo[LocalPlayer():GetActiveWeapon():GetClass()] != nil then
  169.             ammobar=mag_left/MaxAmmo[LocalPlayer():GetActiveWeapon():GetClass()]*180
  170.             mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
  171.         else
  172.             ammobar=mag_left/0*180
  173.             mag_all = "     test"
  174.         end
  175.            
  176.     end
  177.     -- Check for maxclipsize
  178.     if LocalPlayer():GetActiveWeapon().Primary != nil then
  179.         ammobar=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
  180.         mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
  181.         draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "DefaultAmmo", x_ammo_small, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
  182.     -- Do other stuff if we cant find the table
  183.     else
  184.         ammobar=180
  185.        
  186.         draw.SimpleText("Mag: "..mag_left , "DefaultAmmo", x_ammo_small, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
  187.     end
  188.    
  189.     */
  190.    
  191.     -- No Default ammo -> draw no ammo hud
  192.     if hasprim == 0 then
  193.         mag_left = LocalPlayer():GetActiveWeapon():GetPrintName() or LocalPlayer():GetActiveWeapon():GetClass()
  194.         surface.SetDrawColor(0,0,0,200*1)
  195.         surface.DrawOutlinedRect( x_ammo_box, y_ammo_box,w_ammo_bars,h_ammo_bars )
  196.         draw.RoundedBox(0, x_ammo_box, y_ammo_box, w_ammo_bars, h_ammo_bars, Color(25,  25, 25, 150*1))
  197.         draw.SimpleText(mag_left , "DefaultAmmo", x_ammo_small+10, y_ammo_text, Color(255, 255, 255, 255), 0, 0)
  198.         draw.SimpleText("- no ammo -" , "DefaultSmall", x_ammo_small+40, y_ammo_text+15, Color(255, 0, 0, 150), 0, 0)
  199.         return true
  200.     end
  201.    
  202.     draw.RoundedBox(0, x_ammo_box, y_ammo_box, w_ammo_bars, h_ammo_bars, Color(25,  25, 25, 150*hasprim))
  203.     draw.RoundedBox(0, x_ammo_box, y_ammo_box_s, w_ammo_bars, h_ammo_bars, Color(25,  25, 25, 150*hassec))
  204.     if (LocalPlayer():GetActiveWeapon().Primary == nil || LocalPlayer():GetActiveWeapon().Primary.ClipSize == nil) then
  205.         -- Fallback to view weapon name only and a full ammo bar
  206.         ammobar=180
  207.         draw.SimpleText("Mag: "..mag_left, "DefaultAmmo", x_ammo_small+10, y_ammo_text, Color(0, 220, 0, 255*1), 0, 0)
  208.         --:IsValid()
  209.         --if IsValid(LocalPlayer():GetActiveWeapon().Primary.PrintName) then
  210.         --    mag_left = LocalPlayer():GetActiveWeapon().Primary.PrintName
  211.         --else
  212.             mag_left = LocalPlayer():GetActiveWeapon():GetClass()
  213.         --end
  214.         -- Weapon Class Name Print Name is bugged until all sweaps are included!
  215.         draw.SimpleText(mag_left , "DefaultWeapon", x_ammo_small+20, y_ammo_text+33, Color(255, 255, 255, 255), 0, 0)
  216.     else
  217.         -- Show ammo stats
  218.         ammobar=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
  219.         local mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
  220.         draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "DefaultAmmo", x_ammo_small+10, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
  221.     end
  222.    
  223.    
  224.    
  225.     --draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "DefaultAmmo", x_ammo_small, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
  226.     --draw.SimpleText("Ammo: "..mag_all , "DefaultAmmo", x_ammo_small+30, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
  227.     draw.SimpleText(mag_extra , "DefaultAmmo", x_ammo_small+130, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
  228.    
  229.     draw.RoundedBox(0, x_ammo_small, y_ammo_small, ammobar, 10, Color(0,180,0,255*hasprim), 0, 0)
  230.     draw.RoundedBox(0, x_ammo_small, y_ammo_small, ammobar, 4, Color(120,180,120,175*hasprim), 0, 0)
  231.    
  232.     draw.SimpleText("Sec: "..secondary_ammo , "DefaultAmmo", x_ammo_small, y_ammo_text_s, Color(220, 0, 0, 255*hassec), 0, 0)
  233.     draw.RoundedBox(0, x_ammo_small, y_ammo_small_s, math.Clamp(secondary_ammo,0,18)*10,10, Color(200,0,0,255*hassec))
  234.     draw.RoundedBox(0, x_ammo_small, y_ammo_small_s, math.Clamp(secondary_ammo,0,18)*10,4, Color(255,155,155,100*hassec))
  235.    
  236.     surface.SetDrawColor(0,0,0,200*hasprim)
  237.     surface.DrawOutlinedRect( x_ammo_box, y_ammo_box,w_ammo_bars,h_ammo_bars )
  238.     surface.DrawOutlinedRect( x_ammo_small, y_ammo_small,ammobar,10)
  239.     surface.DrawOutlinedRect( x_ammo_small, y_ammo_small,180,10)
  240.    
  241.     surface.SetDrawColor(0,0,0,200*hassec)
  242.     surface.DrawOutlinedRect( x_ammo_box, y_ammo_box_s,w_ammo_bars,h_ammo_bars)
  243.     surface.DrawOutlinedRect( x_ammo_small, y_ammo_small_s,math.Clamp(secondary_ammo,0,18)*10,10)
  244.     surface.DrawOutlinedRect( x_ammo_small, y_ammo_small_s,180,10)
  245.    
  246.     -- HUD Test
  247.     --draw.SimpleText("Health: " .. LocalPlayer():Health() .. "%", "DefaultArmor", 35, ScrH()-350, Color(250, 230, 10, 255), 0, 0)
  248. end
  249.  
  250. -- Raidtimer HUD
  251.  
  252. function GM:DrawRaidtimer()
  253.    
  254.     -- check raidtimer table for running raids
  255.    
  256.     -- Draw timer hud for each raid running
  257.    
  258.     local w = ScrW() / 12
  259.     local h = ScrW() / 22
  260.     local x = 5
  261.     local y = ScrH() - h*22 + 5
  262.  
  263.     local w_bar = ScrW() / 8
  264.     local h_bar = ScrW() / 80
  265.     local x_bar = x + w + 5
  266.     local bar_spacing = ScrW() / 300
  267.  
  268.     surface.SetDrawColor( BasewarsBackgroundColor )
  269.     surface.DrawRect( x, y, w, h )
  270.  
  271.     surface.SetDrawColor( BasewarsBorderColor )
  272.     surface.DrawOutlinedRect( x, y, w, h )
  273.     -- Raidtimer
  274.     local raidColor = BasewarsTextColor
  275.     -- get data from tables...
  276.     local attacker = test1
  277.     local defender = test2
  278.    
  279.     draw.SimpleTextOutlined( tostring( LocalPlayer():Health() ), "DefaultHealth", x + w / 2, y + h / 2, hpColor, 1, 1, 0.5, BasewarsBorderColor )
  280.    
  281.  
  282. end
  283.  
  284.  
  285. /*#################################################
  286. ###     cl_hud_display.lua
  287. #################################################*/
  288.  
  289.  
  290. -- Draw Aim Trace
  291. function DrawAim()
  292.     local trace = LocalPlayer():GetEyeTrace()
  293.     local dist  = trace.StartPos:Distance(trace.HitPos)
  294.     local ent = trace.Entity
  295.    
  296.     -- Checks if the ent is valid
  297.     if ent:IsValid() then
  298.         if ent:IsPlayer() then
  299.             -- Player
  300.             Aim_PlayerName(ent)
  301.         else
  302.             -- None player, must be ent
  303.             if dist <= cfg["hud_tooltiprange"] then
  304.                 -- Dont draw HUD for items
  305.                 if string.match(ent:GetClass(),"bw_item_") then return end
  306.                
  307.                 if string.match(ent:GetClass(),"bw_") || string.match(ent:GetClass(),"prop_door_rotating")then
  308.                     -- Request new data from server!!!!!!!!!!!!!!!
  309.                     BW_request_data( LocalPlayer(), ent )
  310.                     Aim_EntInfo(ent)
  311.                 else
  312.                     return
  313.                 end
  314.             end
  315.         end
  316.     end
  317. end
  318.  
  319.  
  320. function Aim_PlayerName(ent)
  321.     local EyePos = ent:GetAttachment(ent:LookupAttachment("eyes")).Pos
  322.     local pos = EyePos
  323.  
  324.     pos = pos:ToScreen()
  325.    
  326.     draw.SimpleText(ent:Name(),"font_20", pos.x, pos.y-90, team.GetColor(ent:Team( )),1)
  327. end
  328.  
  329. function Aim_EntInfo(ent)
  330.    
  331.     local pos = ent:GetPos()
  332.     pos = pos:ToScreen()
  333.    
  334.     -- Box sizes
  335.     local width = 250
  336.     local height = 65
  337.     --local height = 115
  338.    
  339.     -- Box pos
  340.     local offsetx = ScrW()/2-width/2
  341.     local offsety = ScrH()-height-25
  342.    
  343.     local offsetxmoney
  344.     local offsetymoney
  345.    
  346.     -- A list of all structures that needs power, to make a biger box and power bar
  347.     if ( string.match(ent:GetClass(),"bw_base_props") ) then
  348.         height = height-5
  349.         offsety = offsety - 20
  350.     elseif ( string.match(ent:GetClass(),"bw_struc_spawn") ) then
  351.  
  352.        
  353.     -- Is money vault?
  354.     elseif string.match(ent:GetClass(),"bw_struc_moneyvault") then
  355.    
  356.     -- Is money?
  357.     elseif string.match(ent:GetClass(),"bw_money") then
  358.         local length = string.len(tostring(ent.Money))
  359.         height = height-25
  360.         --width = width-(length*10)
  361.         offsety = offsety - 20
  362.         offsetxmoney = width/2-25
  363.         offsetymoney = 2
  364.     else
  365.     -- this is this case lol -> if string.match(ent:GetClass(),"bw_base_props") then
  366.     -- Is other structure? default for all structures, all have power?
  367.         height = height+20
  368.         offsety = offsety - 20
  369.     end
  370.     --local offsetx = ScrW()-width
  371.     --local offsety = 190
  372.    
  373.     -- Owner name
  374.     local Owner
  375.     local TeamColor
  376.     -- Error protection :D
  377.     if !IsValid(ent.Owner) then
  378.         Owner = " "
  379.         TeamColor = Color(0,0,0,0)
  380.     elseif ent.Owner:GetClass() == "prop_door_rotating" then
  381.         Owner = nil
  382.         TeamColor = Color(0,0,0,0)
  383.     else
  384.         Owner = ent.Owner:GetName()
  385.         TeamColor = team.GetColor(ent.Owner:Team())
  386.     end    
  387.     --Gets the texture id for the brick texture
  388.     -- Get Texture and materials use this examples
  389.     --local tex = surface.GetTextureID("Brick/brickfloor001a")
  390.     --surface.SetTexture(tex)
  391.     --local mat = Material( "vgui/hud_pv" )
  392.     --surface.SetMaterial(mat)    
  393.    
  394.     surface.SetDrawColor(TeamColor)
  395.     -- Draw team colors
  396.     TeamColor.a = TeamColor.a - 10 -- visibility 0-255
  397.     surface.DrawOutlinedRect( offsetx-4-2, offsety-2, width+4, height+4 )
  398.     surface.DrawOutlinedRect( offsetx-4-1, offsety-1, width+2, height+2 )
  399.     TeamColor.a = TeamColor.a - 150 -- visibility 0-255
  400.     draw.RoundedBox( 8, offsetx-4-2, offsety-2, width+4, height+4,TeamColor)
  401.    
  402.     -- Main box + prop aimer
  403.     local aimer = {}
  404.     aimer[1] = {x = offsetx+(width/2)-10, y = offsety-0}
  405.     aimer[2] = {x = offsetx+(width/2)+10, y = offsety-0}
  406.     aimer[3] = {x = pos.x, y = pos.y}
  407.     surface.SetTexture(0)
  408.     surface.SetDrawColor(Color(30, 30, 30,200))
  409.     surface.DrawPoly(aimer)
  410.     draw.RoundedBox( 4, offsetx-4, offsety, width, height,Color(30, 30, 30,200))
  411.    
  412.     -- Ent Name
  413.     local NameColor=ent.Color
  414.     local Name=ent.PrintName or "Unknown"
  415.     --local Name=ent:GetClass()
  416.     local NamePos = offsety + 3
  417.     draw.DrawText(Name, "font_15", offsetx+width/2, NamePos, NameColor,TEXT_ALIGN_CENTER)
  418.    
  419.     -- Draw Owner
  420.     --Owner = ( ent.Owner:GetName() or "Unknown" )
  421.     if Owner != nil then
  422.         local OwnerPos = offsety + 17
  423.         draw.DrawText(Owner, "font_15", offsetx+width-10, OwnerPos, Color(255,255,255,255), TEXT_ALIGN_RIGHT)
  424.     end
  425.    
  426.     -- Level
  427.     if ent.Level != nil && ( ent.Level > 0 ) then
  428.         local LevelPos = offsety + 3
  429.         draw.DrawText("Level: "..ent.Level, "font_15", offsetx+1, LevelPos, Color(255,230,0,255), TEXT_ALIGN_LEFT)
  430.     end
  431.    
  432.    
  433.     if ( ent.Hp != 0 && ent.HpMax ) then
  434.         -- HP Bar
  435.         local HealthBarPos=offsety + 35
  436.         local HealthBarMaxWidth=width-10
  437.         local HealthBarMaxHeight=20
  438.         local MaxHealth=ent.HpMax
  439.            
  440.         local Health = ent.Hp
  441.         local HealthBarWidth=(HealthBarMaxWidth/MaxHealth)*Health
  442.         local DamageColorScale = Color(200-((200/MaxHealth)*Health),(200/MaxHealth)*Health, 0, 255)
  443.            
  444.         draw.RoundedBox(0,offsetx+1, HealthBarPos, HealthBarMaxWidth, HealthBarMaxHeight, Color(0, 0, 0, 255))
  445.         draw.RoundedBox(0,offsetx+1, HealthBarPos, HealthBarWidth, HealthBarMaxHeight, DamageColorScale)
  446.         draw.DrawText(Health.."/"..MaxHealth.." HP", "Default", offsetx+4+(HealthBarMaxWidth/2), HealthBarPos+3, Color(255,255,255,255),TEXT_ALIGN_CENTER)
  447.     end    
  448.     -- Show more stats for other advanced stuff
  449.    
  450.     -- Power & Status
  451.     local PowerPos = offsety + 3
  452.     local PowerColor=Color(0,0,0,0)
  453.     local PowerText = "Offline"
  454.    
  455.     --if ent:GetNWInt( "Power", 0 ) > 1 && !ent:GetNWInt("failed") then
  456.     --if ent:GetNWInt( "Power", 0 ) > 1 then
  457. if ent.PowerMax != nil then
  458.     if ent.PowerMax > 1 then
  459.         if ent.Power == 0 then
  460.             if string.match(ent:GetClass(),"bw_gen_") then
  461.                 PowerText="Online"
  462.                 PowerColor=Color(0,255,0,255)
  463.             else
  464.                 PowerText="Offline"
  465.                 PowerColor=Color(255,0,0,255)
  466.             end
  467.         else
  468.             if ent.Inactive == 1 then
  469.                 PowerText="Inactive"
  470.                 PowerColor=Color(255,0,0,255)
  471.             else
  472.                 PowerText="Online"
  473.                 PowerColor=Color(0,255,0,255)
  474.             end
  475.         end
  476.        
  477.         -- Power Bar
  478.         local PowerBarPos=offsety + 60
  479.         local PowerBarMaxWidth=width-10
  480.         local PowerBarMaxHeight=20
  481.         local MaxPower=ent.PowerMax
  482.        
  483.         --local Power = math.Round(ent.Power, MaxPower )
  484.         local Power = ent.Power
  485.         local PowerBarWidth=(PowerBarMaxWidth/MaxPower)*Power
  486.         local PowerColorScale = Color(200-((200/MaxPower)*Power),(200/MaxPower)*Power, 0, 255)
  487.        
  488.         draw.RoundedBox(0, offsetx+1, PowerBarPos, PowerBarMaxWidth, PowerBarMaxHeight, Color(0, 0, 0, 255))
  489.         draw.RoundedBox(0, offsetx+1, PowerBarPos, PowerBarWidth, PowerBarMaxHeight, PowerColorScale)
  490.         draw.DrawText(Power.."/"..MaxPower.." Watt", "Default", offsetx+4+(PowerBarMaxWidth/2), PowerBarPos+3, Color(255,255,255,255),TEXT_ALIGN_CENTER)
  491.        
  492.         draw.DrawText(PowerText, "font_15", offsetx+width-10, PowerPos, PowerColor, TEXT_ALIGN_RIGHT)
  493.  
  494.     end
  495. end
  496.    
  497.  
  498.     -- Extra entity informations
  499.     -- Printed money
  500. --if !ent.Printed == nil then
  501.     if ( ent.Printed != nil && ent.Printed > 0 ) then
  502.         local MoneyPos = offsety + 17
  503.         --draw.DrawText("Money Made:", "font_15", offsetx+1, MoneyPos, Color(0,255,0,255),TEXT_ALIGN_LEFT)
  504.         draw.DrawText(ent.Printed.." $", "font_15", offsetx, MoneyPos, Color(0,255,0,255),TEXT_ALIGN_LEFT)
  505.    
  506.     end
  507. --end
  508.     -- Money inside
  509.     if ent.Money != nil then
  510.         local MoneyPos = offsety + 17
  511.         --draw.DrawText("Money inside:", "font_15", offsetx+1, MoneyPos, Color(0,255,0,255),TEXT_ALIGN_LEFT)
  512.         draw.DrawText(ent.Money.." $", "font_15", offsetx+offsetxmoney, MoneyPos+offsetymoney, Color(0,255,0,255),TEXT_ALIGN_LEFT)
  513.     end
  514.    
  515.    
  516.    
  517.    
  518.    
  519.    
  520. end
  521.  
  522.  
  523.  
  524. -- HUD Player Notify
  525. /*
  526. net.Receive("HUD_Informer", function()
  527.     local text = net.ReadString()
  528.     local type = net.ReadFloat()
  529.     local time = net.ReadFloat()
  530.     if LocalPlayer():GetInfoNum("bw_showmessages")==nil then
  531.         CreateClientConVar("bw_showmessages", 1, true, false)
  532.     end
  533.     if LocalPlayer():GetInfoNum("bw_shownotify")==nil then
  534.         CreateClientConVar("bw_shownotify", 0, true, false)
  535.     end
  536.     if LocalPlayer():GetInfoNum("bw_messages_warningnotify")==nil then
  537.         CreateClientConVar("bw_messages_warningnotify", 1, true, false)
  538.     end
  539.     if LocalPlayer():GetInfoNum("bw_messages_dontshowincome")==nil then
  540.         CreateClientConVar("bw_messages_dontshowincome", 0, true, false)
  541.     end
  542.     local mode = LocalPlayer():GetInfoNum("bw_showmessages")
  543.     local both = LocalPlayer():GetInfoNum("bw_shownotify")
  544.     local warn = LocalPlayer():GetInfoNum("bw_messages_warningnotify")
  545.     local inc = LocalPlayer():GetInfoNum("bw_messages_dontshowincome")
  546.    
  547.     if mode==0 then
  548.         GAMEMODE:AddNotify(text,type,time)
  549.     elseif mode==1 then
  550.         if inc==0 || type!=2 then
  551.             GAMEMODE:AddMessage(text,type,time)
  552.         end
  553.     end
  554.     if both==1 && mode==1 then
  555.         GAMEMODE:AddNotify(text,type,time)
  556.     end
  557.     // if 'both' is set already, we dont need to put the message twice.
  558.     if warn==1 && mode==1 && both==0 && type==1 then
  559.         GAMEMODE:AddNotify(text,type,time)
  560.     end
  561. end)
  562. */
  563.  
  564. -- HUD Player Informer
  565. local informerarr = {}
  566. function DrawInformer()
  567.     local width = 400
  568.     local height = 180
  569.     local lines = 0
  570.     local linelimit = 14
  571.     draw.RoundedBox( 4, ScrW()-width-4,  4, width, height, Color(30, 30, 30,200))
  572.    
  573.     for k, v in pairs(table.Reverse(informerarr)) do
  574.         if(lines < linelimit ) then
  575.         draw.SimpleText(v.text,"font_15",  ScrW()-width+4, 8+(lines*12), v.color, 0)
  576.         lines = lines + 1
  577.         end
  578.     end
  579. end
  580.  
  581.  
  582.    
  583. net.Receive("HUD_Informer", function()
  584.    
  585.     local tbl = net.ReadTable()
  586.     line = table.getn(informerarr) + 1
  587.     informerarr[line] = {color = Color( tbl[1],tbl[2],tbl[3], 255), text = net.ReadString()}
  588. end)
  589.  
  590.  
  591. /*#################################################
  592. ###     cl_raids.lua
  593. #################################################*/
  594.  
  595. local Scans = {}
  596.  
  597. net.Receive("RadarScan", function( len, pl )
  598.  
  599.  
  600.     local ply = net.ReadEntity()
  601.     local pos = net.ReadVector()
  602.     local num = ply:EntIndex()
  603.     --local num = net.ReadFloat()
  604.     Scans[num] = {}
  605.     Scans[num].Time = CurTime()+10
  606.     Scans[num].Pos = pos
  607.     Scans[num].Ply = ply
  608.  
  609. end)
  610. function clearscan(index)
  611.     //Msg(player.GetByID(index):GetName().."\n")
  612.     Scans[index] = nil
  613. end
  614. function DrawScans()
  615.     for k, v in pairs(Scans) do
  616.         if v!=nil then
  617.             local ply = v.Ply
  618.             if IsValid(ply) then
  619.                 local pos = v.Pos + Vector(0,0,100)
  620.                
  621.                 pos = pos:ToScreen()
  622.                 draw.DrawText( ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color( 0, 0, 0, 255 ), 1 )
  623.                 draw.DrawText( ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor( ply:Team() ), 1 )
  624.                 draw.DrawText( "SCAN", "TargetID", pos.x + 1, pos.y-16 + 1, Color( 0, 0, 0, 255 ), 1 )
  625.                 draw.DrawText( "SCAN", "TargetID", pos.x, pos.y-16, Color(255,0,0,255 ), 1 )
  626.             end
  627.             if v.Time<CurTime() then
  628.                 clearscan(k)
  629.             end
  630.         end
  631.     end
  632. end
  633. hook.Add("HUDPaint", "HUD_DrawScans", DrawScans)
  634.  
  635.  
  636. RaidTimers = {}
  637. function RaidTimer_Remove(name)
  638.     RaidTimers[name] = nil
  639. end
  640.  
  641.  
  642.  
  643.  
  644. -- Receive Raidtimer updates and keep clients in sync
  645. net.Receive("RaidTimer_Update", function( len, pl )
  646.  
  647.     local attacker = net.ReadEntity():EntIndex()
  648.     local defender = net.ReadEntity():EntIndex()
  649.     local time = math.Round(math.abs(net.ReadFloat()))
  650.     local lastlife = net.ReadBit()
  651.    
  652.     if(RaidTimers[attacker] == nil) then
  653.         -- create tables
  654.         RaidTimers[attacker] = { attacker = attacker, defender = defender, time = time, lastlife = lastlife }
  655.        
  656.        
  657.     elseif time > 0 then
  658.         -- update tables
  659.         -- check times
  660.         RaidTimers[attacker].time = time
  661.         RaidTimers[attacker].lastlife = lastlife
  662.        
  663.     --elseif time < 0 then
  664.        
  665.     --    RaidTimers[attacker].time = time
  666.        
  667.     else
  668.        
  669.         RaidTimers[attacker] = nil
  670.        
  671.     end
  672.    
  673. end)
  674. net.Receive("RaidTimer_UpdateStats", function( len, pl )
  675.     local raids = net.ReadEntity():EntIndex()
  676.     if IsValid(RaidTimers[raids]) then RaidTimers[raids].kills = net.ReadFloat() end
  677.    
  678. end)
  679.  
  680. -- Remove
  681. net.Receive("RaidTimer_Remove", function( len, pl )
  682.     local id = net.ReadEntity():EntIndex()
  683.     RaidTimers[id] = nil
  684. end)
  685.  
  686.  
  687.  
  688. function DrawRaidTimer()
  689.     table.SortByMember(RaidTimers, "time", true)
  690.     local lineheight = 40
  691.     local linewidth = 200
  692.    
  693.    
  694.     local i = 0
  695.     for k,v in pairs(RaidTimers) do
  696.        
  697.         local attacker = player.GetByID(k)
  698.         local defender = player.GetByID(v.defender)
  699.         local time = math.Round(v.time)
  700.         local lastlife = v.lastlife
  701.         local kills = tostring(v.kills)
  702.        
  703.        
  704.        
  705.        
  706.         //Checks
  707.         if(v.time < 0) then
  708.             RaidTimer_Remove(k)
  709.         end
  710.    
  711.    
  712.    
  713.    
  714.        
  715.    
  716.    
  717.    
  718.    
  719.    
  720.    
  721.         if(attacker:IsValid() && defender:IsValid()) then
  722.             --print(v.lastlife)
  723.             if lastlife == 1 then
  724.                
  725.                
  726.                 -- Box
  727.                 draw.RoundedBox( 4, 4, 62+(i*(lineheight+5)), linewidth, lineheight, Color( 30, 30, 30, 225))
  728.                
  729.                 local u = 0
  730.                
  731.                 draw.DrawText("Lastlife:", "font_15", 8,  lineheight+40+(i*(lineheight+5)), Color(150, 150, 150, 255),TEXT_ALIGN_LEFT)
  732.                
  733.                 for key, pls in pairs(team.GetPlayers(attacker:Team())) do
  734.                     --print(pls:GetTable().lastlife)
  735.                     -- only show 4 entries!
  736.                     if pls:GetTable().lastlife == pls:Deaths() && u < 4 then
  737.                    
  738.                         -- Lastlife members
  739.                        draw.DrawText(pls:Nick(), "font_15", 60+60*u,  lineheight+40+(i*(lineheight+5)), Color(30,144,255, 255),TEXT_ALIGN_LEFT)
  740.                        
  741.                         u=u+1
  742.                    
  743.                    
  744.                     end
  745.                 end
  746.                
  747.                
  748.                
  749.                
  750.                 -- TIME ON LASTLIFE
  751.                 draw.DrawText(Timestamp_time(math.abs(v.time)), "font_15", linewidth-15, lineheight+62-22+(i*(lineheight+5)), Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
  752.                
  753.                 -- PLY NAME
  754.                 draw.DrawText(team.GetName(attacker:Team()), "font_15", 8,  lineheight+23+(i*(lineheight+5)), Color(200, 0, 0, 255),TEXT_ALIGN_LEFT)
  755.                
  756.                 -- TARGET NAME
  757.                 local def
  758.                 if defender:Team() == 0 then def = defender:GetName() else def = team.GetName(defender:Team()) end
  759.                 draw.DrawText(def, "font_15", 200,  lineheight+23+(i*(lineheight+5)), Color(0, 150, 0, 255),TEXT_ALIGN_RIGHT)
  760.                
  761.             else
  762.                
  763.                 -- Box
  764.                 draw.RoundedBox( 4, 4, 62+(i*(lineheight+5)), linewidth, lineheight, Color( 30, 30, 30, 225))
  765.  
  766.                 -- Time Bar
  767.                 local barwidth = v.time/cfg["raid_time"]*linewidth-10
  768.                 local ColorScale = Color(255-((255/cfg["raid_time"])*v.time),(255/cfg["raid_time"])*v.time, 0, 200)
  769.                 draw.RoundedBox( 0, 8, lineheight+62-24+(i*(lineheight+5)), barwidth, 20, ColorScale)
  770.                 draw.DrawText(Timestamp_time(v.time), "font_15", linewidth/2, lineheight+62-22+(i*(lineheight+5)), Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
  771.                
  772.                 -- ATTACKER NAME
  773.                 draw.DrawText(team.GetName(attacker:Team()), "font_15", 8,  lineheight+23+(i*(lineheight+5)), Color(200, 0, 0, 255),TEXT_ALIGN_LEFT)
  774.                
  775.                 -- TARGET NAME
  776.                 draw.DrawText(defender:Nick(), "font_15", 200,  lineheight+23+(i*(lineheight+5)), Color(0, 150, 0, 255),TEXT_ALIGN_RIGHT)
  777.                
  778.                
  779.                 -- Raid kills
  780.                 --draw.DrawText("Kills", "font_15", 8,  lineheight+50+(i*(lineheight+5)), Color(200, 0, 0, 255),TEXT_ALIGN_LEFT)
  781.                 --draw.DrawText(kills, "font_15", 25,  lineheight+75+(i*(lineheight+5)), Color(0, 0, 0, 255),TEXT_ALIGN_LEFT)
  782.                
  783.                
  784.                 i = i + 1
  785.                
  786.             end
  787.        
  788.  
  789.         end
  790.     end
  791. end
  792. hook.Add("HUDPaint", "HUD_DrawRaidTimer", DrawRaidTimer)
  793.  
  794.  
  795.  
  796.  
  797.  
  798. function Timestamp_time(stamp)
  799.  
  800.     //Hours
  801.     /*
  802.     local hours = 0;
  803.     while(stamp > 60*60)
  804.     {
  805.         stamp = stamp -  60*60;
  806.         hours = hours + 1;
  807.     }
  808.     if(hours < 10)then {hours = "0"..hours;}
  809.     */
  810.     //Mins
  811.     local mins = 0;
  812.     while(stamp > 60) do
  813.    
  814.         stamp = stamp -  60;
  815.         mins = mins + 1;
  816.     end
  817.     if(mins < 10) then mins = "0"..mins end
  818.    
  819.     //Secs
  820.     secs = stamp;
  821.     if(secs < 10) then secs = "0"..secs end
  822.    
  823.     return mins..":"..secs;
  824. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement