• Show player name on sprays, against porn and shock image tags.
    23 replies, posted
Hello, I own a server and sometimes some players are spraying on the wall porn pictures or shock image. I want to have a happy and enjoyable server, but I don't know how to code this, I'm very bad. Also, I'd like to know, if someone can help me to code a little addon to show the player name and their steam id on their tags. It's usefull, if a player see a tag, he can take a screenshot and report it. Also if I see it ingame, I can directly ban him. Thanks you very much for your help! Have a nice day!
Personally I would just override Sprays.
Personally I would just answer his question how he wants it answered.
I already had someone answer this for me, i dont know if im blind or something. Look through my threads you may find it. I must be blind.
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerSpray]Gamemode.PlayerSpray [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] [lua]local pos,ang = pl:GetPos(),pl:EyeAngles()[/lua] I'd personally trace forward from their eye angles until you hit a wall. You could use [b][url=http://wiki.garrysmod.com/?title=Player.GetEyeTrace]Player.GetEyeTrace [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] And then simply compare positions and draw the text in [b][url=http://wiki.garrysmod.com/?title=Cam.Start3D2D]Cam.Start3D2D [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] If they're near the position and aren't facing directly away from the angle.
Well i gave this a try but what is this on about? [code]Warning: You're trying to render in the wrong place. This doesn't play nice with multi-core rendering, so we're not going to let you draw here.[/code] [B]ServerSide Script[/B] [lua]hook.Add("PlayerSpray","Sprays", function ( ply ) Msg("player spray func") trace = ply:GetEyeTrace() if trace.HitWorld then Msg("hit world") umsg.Start("PlayerSpr") umsg.Entity( ply ) umsg.Vector( trace.HitPos ) umsg.End() end end) [/lua] [B]Clientside Script[/B] [lua]usermessage.Hook("PlayerSpr", function ( data ) ply = data:ReadEntity() Vec = data:ReadVector() cam.Start3D2D( Vec, Angle(0, 0, 0), 1 ) draw.DrawText( ply:Nick(), "ScoreboardText", 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER ) cam.End3D2D() end) [/lua]
Draw in [b][url=wiki.garrysmod.com/?title=Gamemode.PostDrawOpaqueRenderables]Gamemode.PostDrawOpaqueRenderables [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
So doing this? [lua]usermessage.Hook("PlayerSpr", function ( data ) Msg("Hook Ran") plya = data:ReadEntity() Vec = data:ReadVector() Msg("VarSet") end) hook.Add("PostDrawOpaqueRenderables", "RoundedBoxHud", function() Msg("Hook Ran2") cam.Start3D2D( Vec, Angle(0, 0, 0), 1 ) Msg("Started 3d2d") draw.DrawText( plya:Nick(), "ScoreboardText", 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER ) cam.End3D2D() end) [/lua]
Kind of. But using a table instead. [editline]12th April 2011[/editline] I might write something to do this 1 sec.
Please do, i cant get it working.
I decided not to go with cam.Start3D2D. [lua] if SERVER then AddCSLuaFile("sprays.lua") local sprays = {} hook.Add("PlayerSpray" , 0 , function(pl) sprays[pl] = pl:GetEyeTrace().HitPos umsg.Start("DrawSprayInfo") umsg.Vector(sprays[pl]) umsg.Entity(pl) umsg.End() end ) return; end local sprays = {} usermessage.Hook("DrawSprayInfo" , function(um) local vec = um:ReadVector() local pl = um:ReadEntity() sprays[pl] = vec end ) -- cos a = |A||B|/A.B hook.Add("RenderScreenspaceEffects" , "DrawSprayInfo" , function() for k , v in pairs(sprays) do local angle = math.abs(math.NormalizeAngle(((v-LocalPlayer():GetPos()):Angle()-LocalPlayer():EyeAngles()).y)) -- I should probably use math.acos.. if v:Distance(LocalPlayer():GetPos()) < 250 and angle < 35 then local p = v:ToScreen() draw.DrawText( k:Nick().."'s spray | "..k:SteamID() , "ScoreboardText", p.x, p.y, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER ) end end end ) [/lua]
Flapadar, your script is very good, thanks you! But it's annoying when the text expand :S. Also, I'd like there isn't not visible angle, and we can see it only if it's in front of us. How to? :(
Change "angle < 35" to "angle < 5" [editline]12th April 2011[/editline] As far as the text expanding, you would need to draw it in cam.Start3D2D which I'm too lazy to do.
Nice! Thanks you very much! :)
[QUOTE=Loucouss;29125633]Flapadar, your script is very good, thanks you! But it's annoying when the text expand :S. Also, I'd like there isn't not visible angle, and we can see it only if it's in front of us. How to? :([/QUOTE] Excuse me but anyone know how to modify the Flapadar's script and to add the "cam.Start3D2D", I really don't know how to proceed to this :S. I'm really sorry if I'm bad... I took few hours to fix it but it always fails :(.
Take a look [b][url=http://wiki.garrysmod.com/?title=Cam.Start3D2D]Cam.Start3D2D [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Admins mods have a spray remover. wonder if you can use smod in garrys mod Edit: Smod = SourceMod.
I use this on my server. Works just fine for us. [lua] if SERVER then AddCSLuaFile("trace_dem_sprays.lua") function ResetSpray( ply ) ply:SetNWVector( "SprayPos", Vector( 0, 0, 0 ) ) end hook.Add( "PlayerInitialSpawn", "ResetSpray", ResetSpray ) function OnSpray( ply ) local pos = ply:GetEyeTrace().HitPos ply:SetNWVector( "SprayPos", pos ) end hook.Add( "PlayerSpray", "HandleSpray", OnSpray ) function ChatCommandSpray(ply, text) if ( text == "!spray" or text == "!spraytrace" or text == "!tracespray") then ply:ConCommand("spraytrace") return "" end end hook.Add("PlayerSay", "ChatCommandSpray", ChatCommandSpray) end -- (end server) if CLIENT then function ShowSprayOwner() local Trace = LocalPlayer():GetEyeTrace() local LookAt = Trace.HitPos local demcounter = 0 for _, pl in pairs(player.GetAll()) do if demcounter > 0 then break end 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 demcounter = demcounter + 1 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) + 31, 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 ) < 600 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]
Haha. Thats the one that was posted in my thread. Do threads get deleted over time cause i cant find the thread.
[url]http://www.facepunch.com/threads/1070123-Drawing-next-to-a-spray[/url]. Perhaps you didn't search on your 20 alt accounts :p
Very good point. Thanks for this. [editline]12th April 2011[/editline] FYI: Queer Flawless is the only alt i have.
[QUOTE=RTM xBEASTx;29134190]Very good point. Thanks for this. [editline]12th April 2011[/editline] FYI: Queer Flawless is the only alt i have.[/QUOTE] You have to earn a name like Flawless and you will never earn it
And the thing is neither will you.
[QUOTE=RTM xBEASTx;29148504]And the thing is neither will you.[/QUOTE] Sorry I only take opinions from people who are not idiots and can actually learn to code without facepunch pushing them every step of the way.
Sorry, you need to Log In to post a reply to this thread.