Advertisement
BazZziliuS

[Client] Ники у игроков

Jul 21st, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. surface.CreateFont( "NickFont", {
  2.     font = "Roboto",
  3.     size = 35,
  4.     weight = 500,
  5.     antialias = true,
  6. } )
  7.  
  8. surface.CreateFont( "NickFontSmall", {
  9.     font = "Roboto",
  10.     size = 25,
  11.     weight = 500,
  12.     antialias = true,
  13. } )
  14.  
  15. local constant = 0.3
  16.  
  17. local colors = {}
  18.  
  19. local function findRandomColor( ply )
  20.     colors[ply:Nick()] = Color( math.random( 2, 17 ) * 15, math.random( 2, 17 ) * 15, math.random( 2, 17 ) * 15 )
  21. end
  22.  
  23. for id, ply in pairs( player.GetAll() ) do
  24.     findRandomColor( ply )
  25. end
  26.  
  27. hook.Add( "PostDrawTranslucentRenderables", "PlyNames", function()
  28.     for id, ply in pairs( player.GetAll() ) do
  29.         local offset
  30.         if !colors[ply:Nick()] then
  31.         findRandomColor( ply )
  32.         end
  33.         if ply:Crouching() then
  34.             offset = Vector( 0, 0, ply:OBBMaxs().z + 30 )
  35.         else
  36.             offset = Vector( 0, 0, ply:OBBMaxs().z + 10 )
  37.         end
  38.         local distance = LocalPlayer():GetPos():Distance( ply:GetPos() )
  39.         local pos = ply:GetPos() + offset
  40.         local ang = EyeAngles()
  41.         local alpha = math.Min( - ( distance * constant ) + 255, 255 )
  42.         local color = Color( 0, 0, 0, alpha )
  43.    
  44.         colors[ply:Nick()].a = alpha
  45.    
  46.         ang:RotateAroundAxis( ang:Forward(), 90 )
  47.         ang:RotateAroundAxis( ang:Right(), 90 )
  48.    
  49.         if ply != LocalPlayer() and ply:Alive() and distance < 900 then
  50.             cam.Start3D2D( pos, ang, 0.25 )
  51.                 draw.SimpleTextOutlined( ply:GetName(), "NickFont", 2, -30, colors[ply:Nick()], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color )
  52.                 draw.SimpleTextOutlined( team.GetName( ply:Team() ), "NickFontSmall", 2, -2, colors[ply:Nick()], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color )
  53.             cam.End3D2D()
  54.         end
  55.     end
  56. end )
  57.  
  58. hook.Add( "HUDDrawTargetID", "DisableID", function() return false end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement