Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. local function IsInDistance(a)
  2.     local function IsLookingAt( ply )
  3.         local yes = ply:GetAimVector():Dot( ( a:GetPos() - ply:GetPos() + Vector( 70 ) ):GetNormalized() )
  4.         return (yes > 0.39)
  5.     end
  6.  
  7.     for i,k in pairs(player.GetAll()) do
  8.         if not IsValid(a) or not a:Alive() then continue end
  9.         if k:isCP() and k:Alive() then
  10.             local tr_eyes = util.TraceLine( {
  11.                     start = k:EyePos() + k:EyeAngles():Forward() * 5,
  12.                     endpos = a:EyePos()
  13.                     mask = CONTENTS_WINDOW
  14.             } )
  15.             local tr_center = util.TraceLine( {
  16.                 start = k:LocalToWorld( k:OBBCenter() ),
  17.                 endpos = a:LocalToWorld( a:OBBCenter() ),
  18.                 filter = k
  19.                 mask = CONTENTS_WINDOW
  20.             } )
  21.             if tr_eyes.Entity == a or tr_center.Entity == a then
  22.                 if IsLookingAt(k) then
  23.                     return true
  24.                 end
  25.             end
  26.         end
  27.     end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement