Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SCALE = 0.05
- surface.CreateFont("nx_hud_nametag_main", {
- size = 4.5 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- font = "Roboto"
- })
- surface.CreateFont("nx_hud_nametag_main1", {
- size = 3.5 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- font = "Roboto"
- })
- surface.CreateFont("nx_hud_nametag_main1_shadow", {
- size = 3.5 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- blursize = 0.4 / SCALE,
- font = "Roboto"
- })
- surface.CreateFont("nx_hud_nametag_main_shadow", {
- size = 4.5 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- blursize = 0.4 / SCALE,
- font = "Roboto"
- })
- surface.CreateFont("nx_hud_nametag_icon", {
- size = 4.5 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- font = NX_ICONFONT
- })
- surface.CreateFont("nx_hud_nametag_icon_shadow", {
- size = 4.5 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- blursize = 0.4 / SCALE,
- font = NX_ICONFONT
- })
- surface.CreateFont("nx_hud_nametag_sub", {
- size = 3/ SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- font = "Roboto"
- })
- surface.CreateFont("nx_hud_nametag_sub_shadow", {
- size = 3 / SCALE,
- weight = 350,
- antialias = true,
- extended = true,
- shadow = false,
- outline = false,
- blursize = 0.4 / SCALE,
- font = "Roboto"
- })
- local roofcache = {}
- local function getroof(car)
- if car:GetParent():IsValid() and car:GetParent():IsVehicle() then
- car = car:GetParent()
- end
- local mdl = car:GetModel()
- if not roofcache[mdl] then
- roofcache[mdl] = car:WorldToLocal(util.TraceLine{start = car:LocalToWorld(Vector(0, 0, car:OBBMaxs().z)), endpos = car:LocalToWorld(Vector(0, 0, car:OBBMins().z)), filter = function(ent) return ent == car end}.HitPos)
- end
- return car:LocalToWorld(roofcache[mdl]).z
- end
- local oy = 0
- local drawables = {}
- local fn = 0
- local ffov = 0
- local fadedist = 512
- local putText = function(str, font, color)
- surface.SetFont(font)
- local w, h = surface.GetTextSize(str)
- oy = oy - h
- surface.SetFont(font .. "_shadow")
- surface.SetTextPos(-w*0.5, oy)
- surface.SetTextColor(color_black)
- surface.DrawText(str)
- surface.SetFont(font)
- surface.SetTextPos(-w*0.5, oy)
- surface.SetTextColor(color)
- surface.DrawText(str)
- end
- local debug_plates = false
- local debug_counter = false
- hook.Add("RenderScene", "NameTags", function(pos, ang, fov)
- fn = FrameNumber()
- ffov = fov
- end)
- hook.Add("PostDrawTranslucentRenderables", "NameTags", function(depth, sky)
- if depth or sky then return end
- local ang = Angle(0, EyeAngles().y - 90, 90)
- local eyepos = EyePos()
- local counter = 0
- local cfn = fn-1
- for pl, fn in pairs(drawables) do
- if not pl:IsValid() then
- drawables[pl] = nil
- continue
- end
- if pl.Alive and not pl:Alive() then continue end
- if cfn ~= fn and (cfn+1)~=fn then continue end -- whether real world or rt scope?
- local eye
- local boneId = pl:LookupBone("ValveBiped.Bip01_Head1")
- if boneId then
- eye = (pl:GetBonePosition(boneId))
- else
- eye = pl:GetPos()
- end
- if pl.InVehicle and pl:InVehicle() then
- eye.z = math.max(eye.z + 9, getroof(pl:GetVehicle()) + 5)
- else
- eye.z = eye.z + 9
- end
- if cfn == fn and eyepos:Distance(eye) > fadedist / math.atan(math.rad(ffov)) then continue end -- compensate for fov
- -- if you're looking through scope it might draw a fuckton of player plates, which sucks
- -- todo: we need to check for aimscope visible box
- counter = counter + 1
- oy = 0
- cam.Start3D2D(eye, ang, SCALE)
- --surface.SetDrawColor(color_white)
- --surface.DrawRect(-256, 0, 512, 4)
- --[==[
- local staticLight = render.ComputeLighting(eye, vector_up)
- local dynamicLight = render.ComputeDynamicLighting(eye, vector_up)
- local bothLight = Vector(math.max(staticLight.x, dynamicLight.x), math.max(staticLight.y, dynamicLight.y), math.max(staticLight.z, dynamicLight.z))
- bothLight = math.max(bothLight.x, bothLight.y, bothLight.z)
- local dot = LocalPlayer():GetAimVector():Dot((eye - LocalPlayer():EyePos()):GetNormalized())
- if --[[LocalPlayer():EyePos():Distance(eye) < 64 or]] (LocalPlayer():FlashlightIsOn() and dot > 0.85) then
- bothLight = (dot-0.85)/(1-0.85)
- end
- surface.SetAlphaMultiplier(bothLight)
- ]==]
- if pl:SteamID() == "STEAM_0:0:57441420" then
- local sin = math.sin(RealTime() * 2)
- local flash = HSVToColor(sin > 155 and 0 or 255, math.abs(sin), 1)
- putText("[₯₰۞]", "nx_hud_nametag_main1", flash)
- end
- if pl:SteamID() == "STEAM_0:1:66748167" then
- local sin = math.sin(RealTime() * 2)
- local flash = HSVToColor(sin > 255 and 0 or 255, math.abs(sin), 1)
- putText("[殺す]", "nx_hud_nametag_main1", flash)
- end
- if pl:IsPlayer() then
- putText(pl:Name(), "nx_hud_nametag_main", color_white)
- putText(pl:getDarkRPVar("job") or team.GetName(pl:Team()), "nx_hud_nametag_sub", team.GetColor(pl:Team()))
- if debug_plates or pl:getDarkRPVar("HasGunlicense") then
- putText("Имеется лицензия", "nx_hud_nametag_sub", color_white)
- end
- if debug_plates or pl:getDarkRPVar("wantedReason") then
- local sin = math.sin(RealTime() * 8)
- local flash = HSVToColor(sin > 0 and 0 or 240, math.abs(sin), 1)
- putText("В розыске: ".. pl:getDarkRPVar("wantedReason"), "nx_hud_nametag_sub", flash)
- end
- local icons = {}
- if pl:IsTyping() or debug_plates then
- table.insert(icons, "j")
- end
- if pl:IsSpeaking() or debug_plates then
- table.insert(icons, "g")
- end
- --surface.SetAlphaMultiplier(1)
- cam.End3D2D()
- end
- if debug_counter then print(counter) end
- end
- end)
- hook.Add("UpdateAnimation", "NameTags", function(pl)
- if pl == LocalPlayer() and not pl:ShouldDrawLocalPlayer() then return end
- drawables[pl] = fn
- end)
- function nametagsDrawablesAdd(ent)
- drawables[ent] = fn
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement