• Marking players
    9 replies, posted
Is it possible to mark players similar to how it is in payday 2 in glua? [T]http://cloud-4.steampowered.com/ugc/902140326839558161/20D268AFAA3F3F7187E98765454B8EC3B1E16F4D/[/T]
Yeah, halo.Add
I'm trying to make a swep that marks players when clicked on but it hasn't been going very well. I tried some code that Acecool recommended in a post about halos but it hasn't worked for me, here is the code of the PrimaryAttack function. [CODE]function SWEP:PrimaryAttack() if(CLIENT) then return end local trace = util.TraceLine(tracedata) local tr = trace.Entity local pos = self.Owner:GetShootPos() local ang = self.Owner:GetAimVector() local _color = tr:GetAccessLevelColor( ); local _sin = math.sinwave( 5, 1.5, true ); local tracedata = {} tracedata.start = pos tracedata.endpos = pos + ang * 10000 tracedata.filter = self.Owner if(trace.Hit) then if(trace.Entity) then if(trace.Entity:IsValid()) then if(tr:IsPlayer()) then effects.halo.Add( { tr }, _color, 1 + _sin, 1 + _sin, 1 ) end end end end end [/CODE]
halo.Add needs to be called in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/halo/Add]halo.Add[/url] Here is a very basic and simple example that should help you get started, it should 'tag' a player to be visible through walls like you wanted for 3 seconds. I haven't bothered to test or even re-read this small script so I can't guarantee that it works, but it should give you the general idea of what you have to do. [code]SWEP.TagDuration = 3 function SWEP:PrimaryAttack() local ent = self:GetOwner():GetEyeTrace().Entity if IsValid(ent) and ent:IsPlayer() then ent:SetNWInt("TaggedUntil", CurTime() + self.TagDuration) end end hook.Add("PreDrawHalos", "TaggedPlayerHalos", function() local plys = {} for _, v in pairs(player.GetAll()) do if v:GetNWInt("TaggedUntil", 0) > CurTime() then table.insert(plys, v) end end halo.Add(plys, Color(240, 20, 20), 2, 2, 1, true, false) end)[/code]
[QUOTE=xaviergmail;46667231]halo.Add needs to be called in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/halo/Add]halo.Add[/url] Here is a very basic and simple example that should help you get started, it should 'tag' a player to be visible through walls like you wanted for 3 seconds. I haven't bothered to test or even re-read this small script so I can't guarantee that it works, but it should give you the general idea of what you have to do. [code]SWEP.TagDuration = 3 function SWEP:PrimaryAttack() local ent = self:GetOwner():GetEyeTrace().Entity if IsValid(ent) and ent:IsPlayer() then ent:SetNWInt("TaggedUntil", CurTime() + self.TagDuration) end end hook.Add("PreDrawHalos", "TaggedPlayerHalos", function() local plys = {} for _, v in pairs(player.GetAll()) do if v:GetNWInt("TaggedUntil", 0) > CurTime() then table.insert(plys, v) end end halo.Add(plys, Color(240, 20, 20), 2, 2, 1, true, false) end)[/code][/QUOTE] You mean it needs to be called in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PreDrawHalos]PreDrawHalos[/url]
[QUOTE=siranderson66;46667726]You mean it needs to be called in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PreDrawHalos]PreDrawHalos[/url][/QUOTE] Yeah, copied from wrong tab lol
Is halo.Add still problematic? i.e causes crashing/frame drops
this always caused several frame drops
[QUOTE=NiandraLades;46683602]Is halo.Add still problematic? i.e causes crashing/frame drops[/QUOTE] It always will cause an FPS drop because it renders the entity several times over. Exact number of rerenders is controlled by passes argument.
I used to have issues with Halos on my old laptop... But I think it suddenly fixed.
Sorry, you need to Log In to post a reply to this thread.