Hi!
I am now making a name system for a gamemode.
The situation is that I don't want to can see them when i'm on the otherside of a wall or something physics
so I use util.TraceLine() and trace.Hit.
The problem is : If the trace hit the weapon of the traced player then the name doesn't appear :|
Also, if I use trace.HitWorld then I will see the names through the door and the props.
Thanks for your futur help!
This is my code:
[lua]
for _, pl in ipairs( player.GetAll() ) do
if not pl == LocalPlayer() then
local tl = {}
tl.start = LocalPlayer():GetShootPos()
tl.endpos = pl:GetShootPos()
local trace = util.TraceLine( tl )
if ( !trace.Hit)then
if pl:Alive() then
-- the name system
end
end
end
end
[/lua]
Marc0303
P.S. Sorry for my bad english, it's not my fist languge xS
You'll want tl.endpos to be pl:EyePos() or something similar. You also want to, instead of tr.Hit, use tr.Entity == pl. Finally, add tl.filter = LocalPlayer() so that the LocalPlayer isn't hit by the trace. Otherwise should work.
Note if you want to draw something for every person who is visible, use [B][URL="http://wiki.garrysmod.com/?title=Vector.ToScreen"]Vector.ToScreen [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] instead by finding pl's position, using that function, and checking if the returned result's .visible is true
I tested it but... it doesn't work.
BUT, I had an idea!
If I do something like:
tl.filter = pl:GetActiveWeapon() (or something like that)
Does it will work?
EDIT: What is the entity of target's weapon?
Sorry, you need to Log In to post a reply to this thread.