CapsAdmin

Untitled

Apr 6th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. local snappos
  2. local snapent
  3.  
  4. concommand.Add("+ohsnap", function(ply)
  5.     local res = ply:GetEyeTrace()
  6.  
  7.    
  8.    
  9.     if IsValid(res.Entity) then
  10.         snapent = res.Entity
  11.         snappos = snapent:WorldToLocal(res.HitPos)
  12.     else
  13.         snappos = res.HitPos
  14.     end
  15. end)
  16.  
  17. concommand.Add("-ohsnap", function()
  18.     snappos = nil
  19.     snapent = nil
  20. end)
  21.  
  22. local pos
  23. local ang
  24.  
  25. hook.Add("CalcView", "ohsnap:CalcView", function(ply, origin)
  26.     if not snappos then return end
  27.    
  28.     if IsValid(snapent) then
  29.         pos = snapent:LocalToWorld(snappos)
  30.     else
  31.         pos = snappos
  32.     end
  33.    
  34.     ang = (pos - origin):Angle()
  35.    
  36.     ply:SetEyeAngles(ang)
  37.    
  38.     if snappos then
  39.         return {angles = ang}
  40.     end
  41.    
  42. end)
Advertisement
Add Comment
Please, Sign In to add comment