Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. local SCALE = 0.05
  2.  
  3. surface.CreateFont("nx_hud_nametag_main", {
  4. size = 4.5 / SCALE,
  5. weight = 350,
  6. antialias = true,
  7. extended = true,
  8. shadow = false,
  9. outline = false,
  10. font = "Roboto"
  11. })
  12.  
  13. surface.CreateFont("nx_hud_nametag_main1", {
  14. size = 3.5 / SCALE,
  15. weight = 350,
  16. antialias = true,
  17. extended = true,
  18. shadow = false,
  19. outline = false,
  20. font = "Roboto"
  21. })
  22.  
  23. surface.CreateFont("nx_hud_nametag_main1_shadow", {
  24. size = 3.5 / SCALE,
  25. weight = 350,
  26. antialias = true,
  27. extended = true,
  28. shadow = false,
  29. outline = false,
  30. blursize = 0.4 / SCALE,
  31. font = "Roboto"
  32. })
  33.  
  34.  
  35.  
  36. surface.CreateFont("nx_hud_nametag_main_shadow", {
  37. size = 4.5 / SCALE,
  38. weight = 350,
  39. antialias = true,
  40. extended = true,
  41. shadow = false,
  42. outline = false,
  43. blursize = 0.4 / SCALE,
  44. font = "Roboto"
  45. })
  46.  
  47. surface.CreateFont("nx_hud_nametag_icon", {
  48. size = 4.5 / SCALE,
  49. weight = 350,
  50. antialias = true,
  51. extended = true,
  52. shadow = false,
  53. outline = false,
  54. font = NX_ICONFONT
  55. })
  56.  
  57. surface.CreateFont("nx_hud_nametag_icon_shadow", {
  58. size = 4.5 / SCALE,
  59. weight = 350,
  60. antialias = true,
  61. extended = true,
  62. shadow = false,
  63. outline = false,
  64. blursize = 0.4 / SCALE,
  65. font = NX_ICONFONT
  66. })
  67.  
  68. surface.CreateFont("nx_hud_nametag_sub", {
  69. size = 3/ SCALE,
  70. weight = 350,
  71. antialias = true,
  72. extended = true,
  73. shadow = false,
  74. outline = false,
  75. font = "Roboto"
  76. })
  77.  
  78. surface.CreateFont("nx_hud_nametag_sub_shadow", {
  79. size = 3 / SCALE,
  80. weight = 350,
  81. antialias = true,
  82. extended = true,
  83. shadow = false,
  84. outline = false,
  85. blursize = 0.4 / SCALE,
  86. font = "Roboto"
  87. })
  88.  
  89.  
  90.  
  91. local roofcache = {}
  92. local function getroof(car)
  93. if car:GetParent():IsValid() and car:GetParent():IsVehicle() then
  94. car = car:GetParent()
  95. end
  96.  
  97. local mdl = car:GetModel()
  98. if not roofcache[mdl] then
  99. 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)
  100. end
  101. return car:LocalToWorld(roofcache[mdl]).z
  102. end
  103.  
  104.  
  105. local oy = 0
  106. local drawables = {}
  107. local fn = 0
  108. local ffov = 0
  109. local fadedist = 512
  110.  
  111. local putText = function(str, font, color)
  112. surface.SetFont(font)
  113.  
  114. local w, h = surface.GetTextSize(str)
  115. oy = oy - h
  116.  
  117. surface.SetFont(font .. "_shadow")
  118.  
  119. surface.SetTextPos(-w*0.5, oy)
  120. surface.SetTextColor(color_black)
  121. surface.DrawText(str)
  122.  
  123. surface.SetFont(font)
  124.  
  125. surface.SetTextPos(-w*0.5, oy)
  126. surface.SetTextColor(color)
  127. surface.DrawText(str)
  128. end
  129.  
  130. local debug_plates = false
  131. local debug_counter = false
  132.  
  133. hook.Add("RenderScene", "NameTags", function(pos, ang, fov)
  134. fn = FrameNumber()
  135. ffov = fov
  136. end)
  137.  
  138. hook.Add("PostDrawTranslucentRenderables", "NameTags", function(depth, sky)
  139. if depth or sky then return end
  140.  
  141. local ang = Angle(0, EyeAngles().y - 90, 90)
  142. local eyepos = EyePos()
  143.  
  144. local counter = 0
  145. local cfn = fn-1
  146. for pl, fn in pairs(drawables) do
  147. if not pl:IsValid() then
  148. drawables[pl] = nil
  149. continue
  150. end
  151.  
  152. if pl.Alive and not pl:Alive() then continue end
  153. if cfn ~= fn and (cfn+1)~=fn then continue end -- whether real world or rt scope?
  154.  
  155. local eye
  156.  
  157. local boneId = pl:LookupBone("ValveBiped.Bip01_Head1")
  158. if boneId then
  159. eye = (pl:GetBonePosition(boneId))
  160. else
  161. eye = pl:GetPos()
  162. end
  163.  
  164. if pl.InVehicle and pl:InVehicle() then
  165. eye.z = math.max(eye.z + 9, getroof(pl:GetVehicle()) + 5)
  166. else
  167. eye.z = eye.z + 9
  168. end
  169.  
  170. if cfn == fn and eyepos:Distance(eye) > fadedist / math.atan(math.rad(ffov)) then continue end -- compensate for fov
  171. -- if you're looking through scope it might draw a fuckton of player plates, which sucks
  172. -- todo: we need to check for aimscope visible box
  173.  
  174. counter = counter + 1
  175.  
  176. oy = 0
  177. cam.Start3D2D(eye, ang, SCALE)
  178. --surface.SetDrawColor(color_white)
  179. --surface.DrawRect(-256, 0, 512, 4)
  180.  
  181. --[==[
  182. local staticLight = render.ComputeLighting(eye, vector_up)
  183. local dynamicLight = render.ComputeDynamicLighting(eye, vector_up)
  184.  
  185. local bothLight = Vector(math.max(staticLight.x, dynamicLight.x), math.max(staticLight.y, dynamicLight.y), math.max(staticLight.z, dynamicLight.z))
  186. bothLight = math.max(bothLight.x, bothLight.y, bothLight.z)
  187.  
  188. local dot = LocalPlayer():GetAimVector():Dot((eye - LocalPlayer():EyePos()):GetNormalized())
  189.  
  190. if --[[LocalPlayer():EyePos():Distance(eye) < 64 or]] (LocalPlayer():FlashlightIsOn() and dot > 0.85) then
  191. bothLight = (dot-0.85)/(1-0.85)
  192. end
  193.  
  194. surface.SetAlphaMultiplier(bothLight)
  195. ]==]
  196.  
  197. if pl:SteamID() == "STEAM_0:0:57441420" then
  198. local sin = math.sin(RealTime() * 2)
  199. local flash = HSVToColor(sin > 155 and 0 or 255, math.abs(sin), 1)
  200.  
  201. putText("[₯₰۞]", "nx_hud_nametag_main1", flash)
  202. end
  203.  
  204.  
  205. if pl:SteamID() == "STEAM_0:1:66748167" then
  206. local sin = math.sin(RealTime() * 2)
  207. local flash = HSVToColor(sin > 255 and 0 or 255, math.abs(sin), 1)
  208.  
  209. putText("[殺す]", "nx_hud_nametag_main1", flash)
  210. end
  211.  
  212. if pl:IsPlayer() then
  213. putText(pl:Name(), "nx_hud_nametag_main", color_white)
  214. putText(pl:getDarkRPVar("job") or team.GetName(pl:Team()), "nx_hud_nametag_sub", team.GetColor(pl:Team()))
  215.  
  216. if debug_plates or pl:getDarkRPVar("HasGunlicense") then
  217. putText("Имеется лицензия", "nx_hud_nametag_sub", color_white)
  218. end
  219.  
  220. if debug_plates or pl:getDarkRPVar("wantedReason") then
  221. local sin = math.sin(RealTime() * 8)
  222. local flash = HSVToColor(sin > 0 and 0 or 240, math.abs(sin), 1)
  223.  
  224. putText("В розыске: ".. pl:getDarkRPVar("wantedReason"), "nx_hud_nametag_sub", flash)
  225. end
  226.  
  227. local icons = {}
  228. if pl:IsTyping() or debug_plates then
  229. table.insert(icons, "j")
  230. end
  231. if pl:IsSpeaking() or debug_plates then
  232. table.insert(icons, "g")
  233. end
  234.  
  235. --surface.SetAlphaMultiplier(1)
  236. cam.End3D2D()
  237. end
  238.  
  239. if debug_counter then print(counter) end
  240. end
  241. end)
  242.  
  243. hook.Add("UpdateAnimation", "NameTags", function(pl)
  244. if pl == LocalPlayer() and not pl:ShouldDrawLocalPlayer() then return end
  245.  
  246. drawables[pl] = fn
  247. end)
  248.  
  249. function nametagsDrawablesAdd(ent)
  250. drawables[ent] = fn
  251. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement