Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*#################################################
- ### cl_hud.lua
- #################################################*/
- surface.CreateFont( "DefaultSmall", {
- font = "Tahoma",
- size = ScreenScale( 7 ),
- weight = 500
- } )
- surface.CreateFont( "DefaultHealth", {
- font = "Tahoma",
- size = ScreenScale( ScrH()/34 ),
- weight = 900
- } )
- surface.CreateFont( "DefaultArmor", {
- font = "Tahoma",
- size = ScreenScale( 30 ),
- weight = 900
- } )
- surface.CreateFont( "DefaultAmmo", {
- font = "Tahoma",
- size = ScreenScale( 6 ),
- weight = 500
- } )
- surface.CreateFont( "DefaultWeapon", {
- font = "Tahoma",
- size = ScreenScale( 5 ),
- weight = 300
- } )
- function TestDrawHud()
- local struc = {}
- struc.pos = {}
- struc.pos[1] = ScrW()*.5 -- x pos
- --struc.pos[2] = ScrH()*.005 -- y pos
- struc.pos[2] = ScrH()-10 -- y pos
- struc.color = Color(0,0,0,255)
- struc.text = "--- Baswars PreAlpha v0.1 for GMOD13 by .delay ---"
- struc.font = "DefaultFixed" -- Font
- struc.xalign = TEXT_ALIGN_CENTER -- Horizontal Alignment
- struc.yalign = TEXT_ALIGN_CENTER -- Vertical Alignment
- draw.Text( struc )
- end
- hook.Add("HUDPaint", "HUD_TEST", TestDrawHud)
- function GM:DrawBasewarsHUD()
- local w = ScrW() / 12
- local h = ScrW() / 22
- local x = 5
- local y = ScrH() - h - 5
- local w_bar = ScrW() / 8
- local h_bar = ScrW() / 80
- local x_bar = x + w + 5
- local bar_spacing = ScrW() / 300
- surface.SetDrawColor( BasewarsBackgroundColor )
- surface.DrawRect( x, y, w, h )
- surface.SetDrawColor( BasewarsBorderColor )
- surface.DrawOutlinedRect( x, y, w, h )
- -- Health
- local hpColor = BasewarsTextColor
- if ( LocalPlayer():Health() < 25 ) then hpColor = BasewarsHealthColor end
- draw.SimpleTextOutlined( tostring( LocalPlayer():Health() ), "DefaultHealth", x + w / 2, y + h / 2, hpColor, 1, 1, 0.5, BasewarsBorderColor )
- -- Armor
- local amrColor = BasewarsTextColor
- local bar_y = y + h / 2 - h_bar / 2 - h_bar - bar_spacing
- if ( LocalPlayer():Armor() < 25 ) then hpColor = BasewarsHealthColor end
- -- Health & Armor Bars
- local bar_y = y + h / 2 - h_bar / 2
- local amr_w = math.floor( ( LocalPlayer():Armor() / 100 ) * w_bar )
- surface.SetDrawColor( BasewarsBackgroundColor )
- surface.DrawRect( x_bar, bar_y, w_bar, h_bar )
- surface.SetDrawColor( BasewarsArmorColor )
- surface.DrawRect( x_bar, bar_y, amr_w, h_bar )
- surface.SetDrawColor( BasewarsBorderColor )
- surface.DrawOutlinedRect( x_bar, bar_y, w_bar, h_bar )
- draw.SimpleTextOutlined( "Armor: "..tostring( LocalPlayer():Armor() ).."%", "DefaultSmall", x_bar + w_bar / 2, bar_y + h_bar / 2, BasewarsTextColor, 1, 1, 0.5, BasewarsTextShadowColor )
- local bar_y = y + h / 2 - h_bar / 2 + h_bar + bar_spacing
- local health_w = math.floor( ( LocalPlayer():Health() / 100 ) * w_bar )
- surface.SetDrawColor( BasewarsBackgroundColor )
- surface.DrawRect( x_bar, bar_y, w_bar, h_bar )
- surface.SetDrawColor( BasewarsHealthColor )
- surface.DrawRect( x_bar, bar_y, health_w, h_bar )
- surface.SetDrawColor( BasewarsBorderColor )
- surface.DrawOutlinedRect( x_bar, bar_y, w_bar, h_bar )
- draw.SimpleTextOutlined( "Health", "DefaultSmall", x_bar + w_bar / 2, bar_y + h_bar / 2, BasewarsTextColor, 1, 1, 0.5, BasewarsTextShadowColor )
- -- Ammo Bars
- -- This prevents client crash on death. LOL
- -- Dont draw weapon hud if the players wears no valid sweap
- if !LocalPlayer():GetActiveWeapon():IsValid() then return true end
- local mag_left = LocalPlayer():GetActiveWeapon():Clip1()
- local mag_extra = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType())
- local secondary_ammo = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType())
- /*
- MaxAmmo={}
- MaxAmmo["weapon_crowbar"]=0
- MaxAmmo["weapon_physcannon"]=0
- MaxAmmo["weapon_physgun"]=0
- MaxAmmo["weapon_pistol"]=18
- MaxAmmo["weapon_357"]=6
- MaxAmmo["weapon_smg1"]=45
- MaxAmmo["weapon_ar2"]=30
- MaxAmmo["weapon_crossbow"]=1
- MaxAmmo["weapon_frag"]=-1
- MaxAmmo["weapon_rpg"]=-1
- MaxAmmo["chair_launcher"]=-1
- MaxAmmo["weapon_basewars"]=200
- */
- local x_ammo_box = ScrW()-230
- local y_ammo_box = ScrH()-60
- local y_ammo_box_s = ScrH()-105
- local x_ammo_small = ScrW()-220
- local y_ammo_small = ScrH()-35
- local y_ammo_small_s = ScrH()-80
- local y_ammo_text = ScrH()-55
- local y_ammo_text_s = ScrH()-100
- local w_ammo_bars = 200
- local h_ammo_bars = 40
- if mag_left <= 0 && mag_extra <= 0 then
- hasprim=0
- else
- hasprim=1
- end
- if secondary_ammo <= 0 then
- hassec=0
- else
- hassec=1
- end
- -- Draw ammo box
- /*
- -- Check for maxclipsize
- if(LocalPlayer():GetActiveWeapon().Primary)then
- ammobar=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
- mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
- -- Do other stuff if we cant find the table
- else
- if MaxAmmo[LocalPlayer():GetActiveWeapon():GetClass()] != nil then
- ammobar=mag_left/MaxAmmo[LocalPlayer():GetActiveWeapon():GetClass()]*180
- mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
- else
- ammobar=mag_left/0*180
- mag_all = " test"
- end
- end
- -- Check for maxclipsize
- if LocalPlayer():GetActiveWeapon().Primary != nil then
- ammobar=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
- mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
- draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "DefaultAmmo", x_ammo_small, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
- -- Do other stuff if we cant find the table
- else
- ammobar=180
- draw.SimpleText("Mag: "..mag_left , "DefaultAmmo", x_ammo_small, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
- end
- */
- -- No Default ammo -> draw no ammo hud
- if hasprim == 0 then
- mag_left = LocalPlayer():GetActiveWeapon():GetPrintName() or LocalPlayer():GetActiveWeapon():GetClass()
- surface.SetDrawColor(0,0,0,200*1)
- surface.DrawOutlinedRect( x_ammo_box, y_ammo_box,w_ammo_bars,h_ammo_bars )
- draw.RoundedBox(0, x_ammo_box, y_ammo_box, w_ammo_bars, h_ammo_bars, Color(25, 25, 25, 150*1))
- draw.SimpleText(mag_left , "DefaultAmmo", x_ammo_small+10, y_ammo_text, Color(255, 255, 255, 255), 0, 0)
- draw.SimpleText("- no ammo -" , "DefaultSmall", x_ammo_small+40, y_ammo_text+15, Color(255, 0, 0, 150), 0, 0)
- return true
- end
- draw.RoundedBox(0, x_ammo_box, y_ammo_box, w_ammo_bars, h_ammo_bars, Color(25, 25, 25, 150*hasprim))
- draw.RoundedBox(0, x_ammo_box, y_ammo_box_s, w_ammo_bars, h_ammo_bars, Color(25, 25, 25, 150*hassec))
- if (LocalPlayer():GetActiveWeapon().Primary == nil || LocalPlayer():GetActiveWeapon().Primary.ClipSize == nil) then
- -- Fallback to view weapon name only and a full ammo bar
- ammobar=180
- draw.SimpleText("Mag: "..mag_left, "DefaultAmmo", x_ammo_small+10, y_ammo_text, Color(0, 220, 0, 255*1), 0, 0)
- --:IsValid()
- --if IsValid(LocalPlayer():GetActiveWeapon().Primary.PrintName) then
- -- mag_left = LocalPlayer():GetActiveWeapon().Primary.PrintName
- --else
- mag_left = LocalPlayer():GetActiveWeapon():GetClass()
- --end
- -- Weapon Class Name Print Name is bugged until all sweaps are included!
- draw.SimpleText(mag_left , "DefaultWeapon", x_ammo_small+20, y_ammo_text+33, Color(255, 255, 255, 255), 0, 0)
- else
- -- Show ammo stats
- ammobar=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
- local mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
- draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "DefaultAmmo", x_ammo_small+10, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
- end
- --draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "DefaultAmmo", x_ammo_small, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
- --draw.SimpleText("Ammo: "..mag_all , "DefaultAmmo", x_ammo_small+30, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
- draw.SimpleText(mag_extra , "DefaultAmmo", x_ammo_small+130, y_ammo_text, Color(0, 220, 0, 255*hasprim), 0, 0)
- draw.RoundedBox(0, x_ammo_small, y_ammo_small, ammobar, 10, Color(0,180,0,255*hasprim), 0, 0)
- draw.RoundedBox(0, x_ammo_small, y_ammo_small, ammobar, 4, Color(120,180,120,175*hasprim), 0, 0)
- draw.SimpleText("Sec: "..secondary_ammo , "DefaultAmmo", x_ammo_small, y_ammo_text_s, Color(220, 0, 0, 255*hassec), 0, 0)
- draw.RoundedBox(0, x_ammo_small, y_ammo_small_s, math.Clamp(secondary_ammo,0,18)*10,10, Color(200,0,0,255*hassec))
- draw.RoundedBox(0, x_ammo_small, y_ammo_small_s, math.Clamp(secondary_ammo,0,18)*10,4, Color(255,155,155,100*hassec))
- surface.SetDrawColor(0,0,0,200*hasprim)
- surface.DrawOutlinedRect( x_ammo_box, y_ammo_box,w_ammo_bars,h_ammo_bars )
- surface.DrawOutlinedRect( x_ammo_small, y_ammo_small,ammobar,10)
- surface.DrawOutlinedRect( x_ammo_small, y_ammo_small,180,10)
- surface.SetDrawColor(0,0,0,200*hassec)
- surface.DrawOutlinedRect( x_ammo_box, y_ammo_box_s,w_ammo_bars,h_ammo_bars)
- surface.DrawOutlinedRect( x_ammo_small, y_ammo_small_s,math.Clamp(secondary_ammo,0,18)*10,10)
- surface.DrawOutlinedRect( x_ammo_small, y_ammo_small_s,180,10)
- -- HUD Test
- --draw.SimpleText("Health: " .. LocalPlayer():Health() .. "%", "DefaultArmor", 35, ScrH()-350, Color(250, 230, 10, 255), 0, 0)
- end
- -- Raidtimer HUD
- function GM:DrawRaidtimer()
- -- check raidtimer table for running raids
- -- Draw timer hud for each raid running
- local w = ScrW() / 12
- local h = ScrW() / 22
- local x = 5
- local y = ScrH() - h*22 + 5
- local w_bar = ScrW() / 8
- local h_bar = ScrW() / 80
- local x_bar = x + w + 5
- local bar_spacing = ScrW() / 300
- surface.SetDrawColor( BasewarsBackgroundColor )
- surface.DrawRect( x, y, w, h )
- surface.SetDrawColor( BasewarsBorderColor )
- surface.DrawOutlinedRect( x, y, w, h )
- -- Raidtimer
- local raidColor = BasewarsTextColor
- -- get data from tables...
- local attacker = test1
- local defender = test2
- draw.SimpleTextOutlined( tostring( LocalPlayer():Health() ), "DefaultHealth", x + w / 2, y + h / 2, hpColor, 1, 1, 0.5, BasewarsBorderColor )
- end
- /*#################################################
- ### cl_hud_display.lua
- #################################################*/
- -- Draw Aim Trace
- function DrawAim()
- local trace = LocalPlayer():GetEyeTrace()
- local dist = trace.StartPos:Distance(trace.HitPos)
- local ent = trace.Entity
- -- Checks if the ent is valid
- if ent:IsValid() then
- if ent:IsPlayer() then
- -- Player
- Aim_PlayerName(ent)
- else
- -- None player, must be ent
- if dist <= cfg["hud_tooltiprange"] then
- -- Dont draw HUD for items
- if string.match(ent:GetClass(),"bw_item_") then return end
- if string.match(ent:GetClass(),"bw_") || string.match(ent:GetClass(),"prop_door_rotating")then
- -- Request new data from server!!!!!!!!!!!!!!!
- BW_request_data( LocalPlayer(), ent )
- Aim_EntInfo(ent)
- else
- return
- end
- end
- end
- end
- end
- function Aim_PlayerName(ent)
- local EyePos = ent:GetAttachment(ent:LookupAttachment("eyes")).Pos
- local pos = EyePos
- pos = pos:ToScreen()
- draw.SimpleText(ent:Name(),"font_20", pos.x, pos.y-90, team.GetColor(ent:Team( )),1)
- end
- function Aim_EntInfo(ent)
- local pos = ent:GetPos()
- pos = pos:ToScreen()
- -- Box sizes
- local width = 250
- local height = 65
- --local height = 115
- -- Box pos
- local offsetx = ScrW()/2-width/2
- local offsety = ScrH()-height-25
- local offsetxmoney
- local offsetymoney
- -- A list of all structures that needs power, to make a biger box and power bar
- if ( string.match(ent:GetClass(),"bw_base_props") ) then
- height = height-5
- offsety = offsety - 20
- elseif ( string.match(ent:GetClass(),"bw_struc_spawn") ) then
- -- Is money vault?
- elseif string.match(ent:GetClass(),"bw_struc_moneyvault") then
- -- Is money?
- elseif string.match(ent:GetClass(),"bw_money") then
- local length = string.len(tostring(ent.Money))
- height = height-25
- --width = width-(length*10)
- offsety = offsety - 20
- offsetxmoney = width/2-25
- offsetymoney = 2
- else
- -- this is this case lol -> if string.match(ent:GetClass(),"bw_base_props") then
- -- Is other structure? default for all structures, all have power?
- height = height+20
- offsety = offsety - 20
- end
- --local offsetx = ScrW()-width
- --local offsety = 190
- -- Owner name
- local Owner
- local TeamColor
- -- Error protection :D
- if !IsValid(ent.Owner) then
- Owner = " "
- TeamColor = Color(0,0,0,0)
- elseif ent.Owner:GetClass() == "prop_door_rotating" then
- Owner = nil
- TeamColor = Color(0,0,0,0)
- else
- Owner = ent.Owner:GetName()
- TeamColor = team.GetColor(ent.Owner:Team())
- end
- --Gets the texture id for the brick texture
- -- Get Texture and materials use this examples
- --local tex = surface.GetTextureID("Brick/brickfloor001a")
- --surface.SetTexture(tex)
- --local mat = Material( "vgui/hud_pv" )
- --surface.SetMaterial(mat)
- surface.SetDrawColor(TeamColor)
- -- Draw team colors
- TeamColor.a = TeamColor.a - 10 -- visibility 0-255
- surface.DrawOutlinedRect( offsetx-4-2, offsety-2, width+4, height+4 )
- surface.DrawOutlinedRect( offsetx-4-1, offsety-1, width+2, height+2 )
- TeamColor.a = TeamColor.a - 150 -- visibility 0-255
- draw.RoundedBox( 8, offsetx-4-2, offsety-2, width+4, height+4,TeamColor)
- -- Main box + prop aimer
- local aimer = {}
- aimer[1] = {x = offsetx+(width/2)-10, y = offsety-0}
- aimer[2] = {x = offsetx+(width/2)+10, y = offsety-0}
- aimer[3] = {x = pos.x, y = pos.y}
- surface.SetTexture(0)
- surface.SetDrawColor(Color(30, 30, 30,200))
- surface.DrawPoly(aimer)
- draw.RoundedBox( 4, offsetx-4, offsety, width, height,Color(30, 30, 30,200))
- -- Ent Name
- local NameColor=ent.Color
- local Name=ent.PrintName or "Unknown"
- --local Name=ent:GetClass()
- local NamePos = offsety + 3
- draw.DrawText(Name, "font_15", offsetx+width/2, NamePos, NameColor,TEXT_ALIGN_CENTER)
- -- Draw Owner
- --Owner = ( ent.Owner:GetName() or "Unknown" )
- if Owner != nil then
- local OwnerPos = offsety + 17
- draw.DrawText(Owner, "font_15", offsetx+width-10, OwnerPos, Color(255,255,255,255), TEXT_ALIGN_RIGHT)
- end
- -- Level
- if ent.Level != nil && ( ent.Level > 0 ) then
- local LevelPos = offsety + 3
- draw.DrawText("Level: "..ent.Level, "font_15", offsetx+1, LevelPos, Color(255,230,0,255), TEXT_ALIGN_LEFT)
- end
- if ( ent.Hp != 0 && ent.HpMax ) then
- -- HP Bar
- local HealthBarPos=offsety + 35
- local HealthBarMaxWidth=width-10
- local HealthBarMaxHeight=20
- local MaxHealth=ent.HpMax
- local Health = ent.Hp
- local HealthBarWidth=(HealthBarMaxWidth/MaxHealth)*Health
- local DamageColorScale = Color(200-((200/MaxHealth)*Health),(200/MaxHealth)*Health, 0, 255)
- draw.RoundedBox(0,offsetx+1, HealthBarPos, HealthBarMaxWidth, HealthBarMaxHeight, Color(0, 0, 0, 255))
- draw.RoundedBox(0,offsetx+1, HealthBarPos, HealthBarWidth, HealthBarMaxHeight, DamageColorScale)
- draw.DrawText(Health.."/"..MaxHealth.." HP", "Default", offsetx+4+(HealthBarMaxWidth/2), HealthBarPos+3, Color(255,255,255,255),TEXT_ALIGN_CENTER)
- end
- -- Show more stats for other advanced stuff
- -- Power & Status
- local PowerPos = offsety + 3
- local PowerColor=Color(0,0,0,0)
- local PowerText = "Offline"
- --if ent:GetNWInt( "Power", 0 ) > 1 && !ent:GetNWInt("failed") then
- --if ent:GetNWInt( "Power", 0 ) > 1 then
- if ent.PowerMax != nil then
- if ent.PowerMax > 1 then
- if ent.Power == 0 then
- if string.match(ent:GetClass(),"bw_gen_") then
- PowerText="Online"
- PowerColor=Color(0,255,0,255)
- else
- PowerText="Offline"
- PowerColor=Color(255,0,0,255)
- end
- else
- if ent.Inactive == 1 then
- PowerText="Inactive"
- PowerColor=Color(255,0,0,255)
- else
- PowerText="Online"
- PowerColor=Color(0,255,0,255)
- end
- end
- -- Power Bar
- local PowerBarPos=offsety + 60
- local PowerBarMaxWidth=width-10
- local PowerBarMaxHeight=20
- local MaxPower=ent.PowerMax
- --local Power = math.Round(ent.Power, MaxPower )
- local Power = ent.Power
- local PowerBarWidth=(PowerBarMaxWidth/MaxPower)*Power
- local PowerColorScale = Color(200-((200/MaxPower)*Power),(200/MaxPower)*Power, 0, 255)
- draw.RoundedBox(0, offsetx+1, PowerBarPos, PowerBarMaxWidth, PowerBarMaxHeight, Color(0, 0, 0, 255))
- draw.RoundedBox(0, offsetx+1, PowerBarPos, PowerBarWidth, PowerBarMaxHeight, PowerColorScale)
- draw.DrawText(Power.."/"..MaxPower.." Watt", "Default", offsetx+4+(PowerBarMaxWidth/2), PowerBarPos+3, Color(255,255,255,255),TEXT_ALIGN_CENTER)
- draw.DrawText(PowerText, "font_15", offsetx+width-10, PowerPos, PowerColor, TEXT_ALIGN_RIGHT)
- end
- end
- -- Extra entity informations
- -- Printed money
- --if !ent.Printed == nil then
- if ( ent.Printed != nil && ent.Printed > 0 ) then
- local MoneyPos = offsety + 17
- --draw.DrawText("Money Made:", "font_15", offsetx+1, MoneyPos, Color(0,255,0,255),TEXT_ALIGN_LEFT)
- draw.DrawText(ent.Printed.." $", "font_15", offsetx, MoneyPos, Color(0,255,0,255),TEXT_ALIGN_LEFT)
- end
- --end
- -- Money inside
- if ent.Money != nil then
- local MoneyPos = offsety + 17
- --draw.DrawText("Money inside:", "font_15", offsetx+1, MoneyPos, Color(0,255,0,255),TEXT_ALIGN_LEFT)
- draw.DrawText(ent.Money.." $", "font_15", offsetx+offsetxmoney, MoneyPos+offsetymoney, Color(0,255,0,255),TEXT_ALIGN_LEFT)
- end
- end
- -- HUD Player Notify
- /*
- net.Receive("HUD_Informer", function()
- local text = net.ReadString()
- local type = net.ReadFloat()
- local time = net.ReadFloat()
- if LocalPlayer():GetInfoNum("bw_showmessages")==nil then
- CreateClientConVar("bw_showmessages", 1, true, false)
- end
- if LocalPlayer():GetInfoNum("bw_shownotify")==nil then
- CreateClientConVar("bw_shownotify", 0, true, false)
- end
- if LocalPlayer():GetInfoNum("bw_messages_warningnotify")==nil then
- CreateClientConVar("bw_messages_warningnotify", 1, true, false)
- end
- if LocalPlayer():GetInfoNum("bw_messages_dontshowincome")==nil then
- CreateClientConVar("bw_messages_dontshowincome", 0, true, false)
- end
- local mode = LocalPlayer():GetInfoNum("bw_showmessages")
- local both = LocalPlayer():GetInfoNum("bw_shownotify")
- local warn = LocalPlayer():GetInfoNum("bw_messages_warningnotify")
- local inc = LocalPlayer():GetInfoNum("bw_messages_dontshowincome")
- if mode==0 then
- GAMEMODE:AddNotify(text,type,time)
- elseif mode==1 then
- if inc==0 || type!=2 then
- GAMEMODE:AddMessage(text,type,time)
- end
- end
- if both==1 && mode==1 then
- GAMEMODE:AddNotify(text,type,time)
- end
- // if 'both' is set already, we dont need to put the message twice.
- if warn==1 && mode==1 && both==0 && type==1 then
- GAMEMODE:AddNotify(text,type,time)
- end
- end)
- */
- -- HUD Player Informer
- local informerarr = {}
- function DrawInformer()
- local width = 400
- local height = 180
- local lines = 0
- local linelimit = 14
- draw.RoundedBox( 4, ScrW()-width-4, 4, width, height, Color(30, 30, 30,200))
- for k, v in pairs(table.Reverse(informerarr)) do
- if(lines < linelimit ) then
- draw.SimpleText(v.text,"font_15", ScrW()-width+4, 8+(lines*12), v.color, 0)
- lines = lines + 1
- end
- end
- end
- net.Receive("HUD_Informer", function()
- local tbl = net.ReadTable()
- line = table.getn(informerarr) + 1
- informerarr[line] = {color = Color( tbl[1],tbl[2],tbl[3], 255), text = net.ReadString()}
- end)
- /*#################################################
- ### cl_raids.lua
- #################################################*/
- local Scans = {}
- net.Receive("RadarScan", function( len, pl )
- local ply = net.ReadEntity()
- local pos = net.ReadVector()
- local num = ply:EntIndex()
- --local num = net.ReadFloat()
- Scans[num] = {}
- Scans[num].Time = CurTime()+10
- Scans[num].Pos = pos
- Scans[num].Ply = ply
- end)
- function clearscan(index)
- //Msg(player.GetByID(index):GetName().."\n")
- Scans[index] = nil
- end
- function DrawScans()
- for k, v in pairs(Scans) do
- if v!=nil then
- local ply = v.Ply
- if IsValid(ply) then
- local pos = v.Pos + Vector(0,0,100)
- pos = pos:ToScreen()
- draw.DrawText( ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color( 0, 0, 0, 255 ), 1 )
- draw.DrawText( ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor( ply:Team() ), 1 )
- draw.DrawText( "SCAN", "TargetID", pos.x + 1, pos.y-16 + 1, Color( 0, 0, 0, 255 ), 1 )
- draw.DrawText( "SCAN", "TargetID", pos.x, pos.y-16, Color(255,0,0,255 ), 1 )
- end
- if v.Time<CurTime() then
- clearscan(k)
- end
- end
- end
- end
- hook.Add("HUDPaint", "HUD_DrawScans", DrawScans)
- RaidTimers = {}
- function RaidTimer_Remove(name)
- RaidTimers[name] = nil
- end
- -- Receive Raidtimer updates and keep clients in sync
- net.Receive("RaidTimer_Update", function( len, pl )
- local attacker = net.ReadEntity():EntIndex()
- local defender = net.ReadEntity():EntIndex()
- local time = math.Round(math.abs(net.ReadFloat()))
- local lastlife = net.ReadBit()
- if(RaidTimers[attacker] == nil) then
- -- create tables
- RaidTimers[attacker] = { attacker = attacker, defender = defender, time = time, lastlife = lastlife }
- elseif time > 0 then
- -- update tables
- -- check times
- RaidTimers[attacker].time = time
- RaidTimers[attacker].lastlife = lastlife
- --elseif time < 0 then
- -- RaidTimers[attacker].time = time
- else
- RaidTimers[attacker] = nil
- end
- end)
- net.Receive("RaidTimer_UpdateStats", function( len, pl )
- local raids = net.ReadEntity():EntIndex()
- if IsValid(RaidTimers[raids]) then RaidTimers[raids].kills = net.ReadFloat() end
- end)
- -- Remove
- net.Receive("RaidTimer_Remove", function( len, pl )
- local id = net.ReadEntity():EntIndex()
- RaidTimers[id] = nil
- end)
- function DrawRaidTimer()
- table.SortByMember(RaidTimers, "time", true)
- local lineheight = 40
- local linewidth = 200
- local i = 0
- for k,v in pairs(RaidTimers) do
- local attacker = player.GetByID(k)
- local defender = player.GetByID(v.defender)
- local time = math.Round(v.time)
- local lastlife = v.lastlife
- local kills = tostring(v.kills)
- //Checks
- if(v.time < 0) then
- RaidTimer_Remove(k)
- end
- if(attacker:IsValid() && defender:IsValid()) then
- --print(v.lastlife)
- if lastlife == 1 then
- -- Box
- draw.RoundedBox( 4, 4, 62+(i*(lineheight+5)), linewidth, lineheight, Color( 30, 30, 30, 225))
- local u = 0
- draw.DrawText("Lastlife:", "font_15", 8, lineheight+40+(i*(lineheight+5)), Color(150, 150, 150, 255),TEXT_ALIGN_LEFT)
- for key, pls in pairs(team.GetPlayers(attacker:Team())) do
- --print(pls:GetTable().lastlife)
- -- only show 4 entries!
- if pls:GetTable().lastlife == pls:Deaths() && u < 4 then
- -- Lastlife members
- draw.DrawText(pls:Nick(), "font_15", 60+60*u, lineheight+40+(i*(lineheight+5)), Color(30,144,255, 255),TEXT_ALIGN_LEFT)
- u=u+1
- end
- end
- -- TIME ON LASTLIFE
- 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)
- -- PLY NAME
- draw.DrawText(team.GetName(attacker:Team()), "font_15", 8, lineheight+23+(i*(lineheight+5)), Color(200, 0, 0, 255),TEXT_ALIGN_LEFT)
- -- TARGET NAME
- local def
- if defender:Team() == 0 then def = defender:GetName() else def = team.GetName(defender:Team()) end
- draw.DrawText(def, "font_15", 200, lineheight+23+(i*(lineheight+5)), Color(0, 150, 0, 255),TEXT_ALIGN_RIGHT)
- else
- -- Box
- draw.RoundedBox( 4, 4, 62+(i*(lineheight+5)), linewidth, lineheight, Color( 30, 30, 30, 225))
- -- Time Bar
- local barwidth = v.time/cfg["raid_time"]*linewidth-10
- local ColorScale = Color(255-((255/cfg["raid_time"])*v.time),(255/cfg["raid_time"])*v.time, 0, 200)
- draw.RoundedBox( 0, 8, lineheight+62-24+(i*(lineheight+5)), barwidth, 20, ColorScale)
- draw.DrawText(Timestamp_time(v.time), "font_15", linewidth/2, lineheight+62-22+(i*(lineheight+5)), Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
- -- ATTACKER NAME
- draw.DrawText(team.GetName(attacker:Team()), "font_15", 8, lineheight+23+(i*(lineheight+5)), Color(200, 0, 0, 255),TEXT_ALIGN_LEFT)
- -- TARGET NAME
- draw.DrawText(defender:Nick(), "font_15", 200, lineheight+23+(i*(lineheight+5)), Color(0, 150, 0, 255),TEXT_ALIGN_RIGHT)
- -- Raid kills
- --draw.DrawText("Kills", "font_15", 8, lineheight+50+(i*(lineheight+5)), Color(200, 0, 0, 255),TEXT_ALIGN_LEFT)
- --draw.DrawText(kills, "font_15", 25, lineheight+75+(i*(lineheight+5)), Color(0, 0, 0, 255),TEXT_ALIGN_LEFT)
- i = i + 1
- end
- end
- end
- end
- hook.Add("HUDPaint", "HUD_DrawRaidTimer", DrawRaidTimer)
- function Timestamp_time(stamp)
- //Hours
- /*
- local hours = 0;
- while(stamp > 60*60)
- {
- stamp = stamp - 60*60;
- hours = hours + 1;
- }
- if(hours < 10)then {hours = "0"..hours;}
- */
- //Mins
- local mins = 0;
- while(stamp > 60) do
- stamp = stamp - 60;
- mins = mins + 1;
- end
- if(mins < 10) then mins = "0"..mins end
- //Secs
- secs = stamp;
- if(secs < 10) then secs = "0"..secs end
- return mins..":"..secs;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement