Advertisement
Guest User

Rank Icons Job Edition!

a guest
Jun 16th, 2017
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. --[[---------------------------------------------------------------------------
  2. Rank Icons Config
  3. ---------------------------------------------------------------------------]]
  4. local RankIcons = {}
  5. local function mat(texture) return Material(texture, 'smooth') end
  6. local function addRankIcon( rank, icon )
  7.     RankIcons[rank] = {rank = rank, icon = icon}
  8. end
  9. // Do not touch anything above!
  10. -------------------Easy config for you :)
  11. addRankIcon( "Citizen", mat( "icons/div/31.png" ) )
  12. addRankIcon( "Hobo", mat("icons/div/31.png") )
  13. addRankIcon( "Pig Eater", mat("icons/div/31.png") ) ---The rank icon is set based off the job name you set in the DarkRP jobs,
  14. --------you post the image path after mat remeber to use ""
  15. -----------------------------DONT TOUCH ANYTHING BELOW THIS LINE
  16.  
  17. local function DrawRankIcons( self )
  18.  
  19.     local pos = self:EyePos()
  20.     local nick = self:Nick()
  21.  
  22.     pos.z = pos.z + 15 -- Above the head a bit
  23.     pos = pos:ToScreen()
  24.  
  25.     if RankIcons[ team.GetName( self:Team() ) ] then
  26.         surface.SetMaterial( RankIcons[ team.GetName( self:Team() ) ].icon )
  27.         surface.SetDrawColor(255,255,255,255)
  28.         surface.DrawTexturedRect(pos.x - 16, pos.y - 74, 40, 40)
  29.     end
  30.  
  31. end
  32.  
  33. local function NutScripts_RankIconsView()
  34.  
  35.     local LP = LocalPlayer()
  36.     local shootPos = LP:GetShootPos()
  37.     local aimVec = LP:GetAimVector()
  38.     local tr = LP:GetEyeTrace()
  39.     local allPlayers = player.GetAll()
  40.  
  41.     for i = 1, #allPlayers do
  42.  
  43.         local ply = allPlayers[i]
  44.  
  45.         if ply == LP or not ply:Alive() or ply:GetNoDraw() then continue end
  46.  
  47.         local hisPos = ply:GetShootPos()
  48.  
  49.         if hisPos:DistToSqr(shootPos) < 160000 then --Distance from player that it displays
  50.  
  51.             local pos = hisPos - shootPos
  52.  
  53.             local unitPos = pos:GetNormalized()
  54.  
  55.             if unitPos:Dot(aimVec) > 0.45 then
  56.  
  57.                 local trace = util.QuickTrace(shootPos, pos, LP)
  58.  
  59.                 DrawRankIcons(ply)
  60.  
  61.             end
  62.  
  63.         end
  64.  
  65.     end
  66.  
  67. end
  68.  
  69. local function rIHUD()
  70.     NutScripts_RankIconsView()
  71. end
  72. hook.Add("HUDPaint","drawRankIconsHUD",rIHUD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement