Created
April 23, 2014 17:05
-
-
Save CapsAdmin/11223729 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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