General > Developers Corner
Lua Halo Glow Help
JamminR:
Line 16 of the script already seems to try to avoid adding the halo.
--- Code: --- if IsValid(tr.Entity) and !tr.Entity:IsPlayer() then
--- End code ---
You might try changing it to
--- Code: --- if IsValid(tr.Entity) and not IsPlayer(tr.Entity) then
--- End code ---
RainbowHG:
--- Code: ---
[ERROR] lua/autorun/cl_halo.lua:16: attempt to call global 'IsPlayer' (a nil value)
1. fn - lua/autorun/cl_halo.lua:16
2. Run - addons/ulib/lua/ulib/shared/hook.lua:109
3. fn - lua/includes/modules/halo.lua:148
4. unknown - addons/ulib/lua/ulib/shared/hook.lua:109
--- End code ---
Sadly that didn't work.
I've tried changing the trace.filter and adding a if team == but nothing seems to work..
The halo is literally stuck around the player and not any prop.
Here's the code I have
--- Code: ---
function Halos()
local tr = LocalPlayer():GetEyeTraceNoCursor()
local trace = {}
trace.start = tr.StartPos
trace.endpos = trace.start + LocalPlayer():GetAimVector() * 1000
trace.filter = self
trace.mask = MASK_SHOT
if IsValid(tr.Entity) and !tr.Entity:IsPlayer() then
if tr.HitPos:Distance(tr.StartPos) < 500 then -- How Close/Far do you want entities to glow?
local col = Color(255, 255, 0) -- Change the Color here
halo.Add({tr.Entity}, col, 2, 2, 2, true, true)
end
end
end
hook.Add( "PreDrawHalos", "DrawHalos", Halos )
--- End code ---
As you can see the filter is trying to filter out the player but it doesn't seem to work
Here is the trace on the props team
Yet strangly....Here is the trace when a player is a hunter
So it works on the wrong team.
Timmy:
--- Quote from: RainbowHG on November 24, 2017, 01:47:55 AM ---As you can see the filter is trying to filter out the player but it doesn't seem to work
--- End quote ---
1. You are creating a Trace Structure, but you never use it to perform a trace.
Tip: Use a trace function like util.TraceLine to perform the trace.
2. Your filter needs a little bit of tweaking. You don't need to filter a player, but a gamemode prop entity.
Usually, filtering the player entity would suffice, but not in this case. When you're a prop, you're looking directly at a gamemode prop entity, not at a player entity.
I don’t know which Prop Hunt version you are running. There are so many. It looks like most of them have some way to get the prop entity on the client-side. You will have to look at the gamemode source code to figure out how you can get the prop entity.
For example, in Wolvin's Prop Hunt: Enhanced, there's a Player:GetPlayerPropEntity() function.
Navigation
[0] Message Index
[*] Previous page
Go to full version