Skip to content

Instantly share code, notes, and snippets.

@CapsAdmin
Created April 23, 2014 17:05
Show Gist options
  • Select an option

  • Save CapsAdmin/11223729 to your computer and use it in GitHub Desktop.

Select an option

Save CapsAdmin/11223729 to your computer and use it in GitHub Desktop.
local META = FindMetaTable("Player")
local acuracy = 0.95
local min_distance = 30
function META:CanUseNPC()
return ply:EyePos():Distance(npc:EyePos()) < distance and ply:GetAimVector():DotProduct((npc:EyePos() - ply:EyePos()):Normalize() < acuracy)
end
function GAMEMODE:KeyPress()
if key == IN_USE then
for key, npc in pairs(ents.FindByClass("npc*")) do
if ply:CanUseNPC(npc) then
GAMEMODE:PlayerUseNPC(ply, npc)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment