Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local res = {
- "weapon_physgun",
- "weapon_physcannon",
- "gmod_tool",
- "gmod_camera"
- }
- local playere = FindMetaTable("Player")
- function playere:EyeVisible(ent)
- if (not IsValid(ent)) then
- return
- end
- local trace = { start = self:LocalToWorld(self:OBBCenter()), endpos = ent:LocalToWorld(ent:OBBCenter()), filter = { self, ent }, mask = 1174421507 }
- local tr = util.TraceLine(trace)
- return (tr.Fraction == 1)
- end
- local target = NULL
- local lock = false
- hook.Remove("CreateMove", "lel")
- hook.Add("CreateMove", "lel", function( cmd )
- local wep = LocalPlayer():GetActiveWeapon()
- if IsValid(wep) then
- if not table.HasValue(res, wep:GetClass()) then
- local wep = LocalPlayer():GetActiveWeapon()
- if IsValid(wep) and wep.Primary != nil then
- wep.Primary.Recoil = 0
- wep.Primary.Cone = 0
- end
- if lock == false and target == NULL then
- target = LocalPlayer():GetEyeTrace().Entity
- lock = true
- end
- if not LocalPlayer():EyeVisible(target) then
- lock = false
- target = NULL
- end
- if target ~= NULL then
- if target:Health() <= 0 then
- lock = false
- target = NULL
- end
- end
- if target ~= NULL and target:IsPlayer() or target:IsNPC() then
- local targethead = target:LookupBone("ValveBiped.Bip01_Spine")
- if targethead != nil and lock == true then
- local targetheadpos, targetheadang = target:GetBonePosition(targethead)
- cmd:SetViewAngles((targetheadpos-LocalPlayer():GetShootPos()):Angle())
- end
- elseif not IsValid(target) then
- lock = false
- target = NULL
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement