Reliable way to check for the player you're looking at
3 replies, posted
Hello!
I'm trying to find a Reliable way to check for the player you're looking at, this is why:
= I have 2 Lua files =
• Lua file 1
• Lua file 2
Lua file 1 checks if you're looking at the player on primary attack and then Lua file 1 sends a command:
local tr = self.Owner:GetEyeTrace().Entity
if not tr:IsValid() then return end
self.Owner:ConCommand( CommandHere )
Lua file 2 then runs the command with a function and a check for the victim:
concommand.Add( CommandHere, function( ply, cmd, args )
local plyVictim = plyAttacker:GetEyeTrace().Entity
if plyVictim == nil or !plyVictim:IsValid() then return end
The problem is:
Lua File 1 finds the "tr/Victim" as TRUE while Lua file 2 sometimes finds "tr/Victim" as FALSE.
Is there a more reliable way to check in Lua file 2 for the Victim?
Thanks.
See the example here: Vector/Dot
How would I find the entity the player is looking at from the direction he's looking at?
What if there are 2 players that are at the same direction away from you?
Nevermind! I found a fix!
All I had to do was use a global variable in lua file one, include it in lua file 2 and use the global variable, it was connected to the victim.
Thanks for your help anyway, I'll give you the points for at least trying to help!
Sorry, you need to Log In to post a reply to this thread.