• Manipulating player sprays?
    3 replies, posted
Hey, So I'm using something alike the following on my server, which does work nicely: [lua] if SERVER then AddCSLuaFile("trace_dem_sprays.lua") function ResetSpray( pl ) pl:SetNWVector( "SprayPos", Vector( 0, 0, 0 ) ) end hook.Add( "PlayerInitialSpawn", "ResetSpray", ResetSpray ) function OnSpray( pl ) local pos = pl:GetEyeTrace().HitPos pl:SetNWVector( "SprayPos", pos ) end hook.Add( "PlayerSpray", "HandleSpray", OnSpray ) end -- (end server) if CLIENT then function ShowSprayOwner() local Trace = LocalPlayer():GetEyeTrace() local LookAt = Trace.HitPos for _, pl in pairs(player.GetAll()) do local SPos = pl:GetNWVector( "SprayPos" ) if SPos != Vector(0, 0, 0) and LookAt:Distance( SPos ) < 32 and Trace.HitWorld and LocalPlayer():GetPos():Distance( SPos ) < 400 then local Text = pl:Nick() .. "'s Spray" local Text2 = pl:SteamID() surface.SetFont( "ScoreboardText" ) local w, h = surface.GetTextSize( Text ) local w2, h2 = surface.GetTextSize( Text2 ) w = w + 5 h = h + 5 w2 = w2 + 5 h2 = h2 + 5 draw.WordBox( 6, ScrW() / 2 - w / 2, ScrH() / 2 - h / 2, Text, "ScoreboardText", Color( 0, 0, 0, 200 ), team.GetColor( pl:Team() ) ) draw.WordBox( 6, ScrW() / 2 - w2 / 2, (ScrH() / 2 - h2 / 2) + 32, Text2, "ScoreboardText", Color( 0, 0, 0, 200 ), Color(255,255,255,255) ) end end end hook.Add( "HUDPaint", "ShowSprayOwner", ShowSprayOwner ) function PrintSprayOwner() local Trace = LocalPlayer():GetEyeTrace() local LookAt = Trace.HitPos for _, pl in pairs(player.GetAll()) do local SPos = pl:GetNWVector( "SprayPos" ) if SPos != Vector(0, 0, 0) and LookAt:Distance( SPos ) < 32 and Trace.HitWorld and LocalPlayer():GetPos():Distance( SPos ) < 400 then local Text = pl:Nick() .. "'s" local Text2 = pl:SteamID() chat.AddText(team.GetColor( pl:Team() ),Text,Color(255,255,255,255),Text2,team.GetColor( pl:Team() ),"Spray" ) end end end concommand.Add("spraytrace",PrintSprayOwner) end -- (end client) [/lua] What would be the best way to detect if sprays overlap? How could I then go about adding a command to remove the spray?
Sorry for the so recent bump, just really hoping someone has some ways of doing what I mentioned above? I was thinking that perhaps each player spray creates a new entity, but when checking for this both client and server side, entity count stayed exactly the same before and after spraying :(
Sorry this is 4 days late but one idea is that all sprays are sprayed the same size no matter the size of the actual spray. so you could get the spraypos + the size then detect if another spraypos + size is within the last. I hope you get what I mean.
[QUOTE=vexx21322;27667361]Sorry this is 4 days late but one idea is that all sprays are sprayed the same size no matter the size of the actual spray. so you could get the spraypos + the size then detect if another spraypos + size is within the last. I hope you get what I mean.[/QUOTE] Yeah, I did it slightly different, and simply added a counter into the for loop, and once it exceeded 1, broke out of it. Thanks a lot anyways.
Sorry, you need to Log In to post a reply to this thread.