• Banning if sentence contains word
    34 replies, posted
[QUOTE=Robotboy655;46810178][code] local bannedWords = { "fuck", "suck", "dick", "moron", -- DO NOT FORGET THE COMMAS!!! COMMA AFTER LAST ELEMENT IS OK IN LUA. } hook.Add( "PlayerSay", "blocked_words", function( ply, text, public ) text = string.lower( text ) -- Make the chat message entirely lowercase local t = txt for id, str in pairs( bannedWords ) do -- Loop through all the banned words if ( string.find( text, str ) ) then -- If the text contains the banned word, do this: -- Ban the bad person, uncomment to make it work -- ply:Ban( 1440 ) ply:Kick( "Don't use bad words fag" ) local s, e = string.find( text, str ) t = string.gsub( t, string.sub(t, s,e), string.rep("*", e-s) ) -- remember, you can't put code after return in the same scope! return "" -- Hide the entire message, comment this out if you want to just hide the bad words. end end return t -- Hide the bad words end )[/code] I did not test it.[/QUOTE] [code] local bannedWords = { "spic", "nig", "ass", "ddos", } [/code] [ server lags ] User1: is this ddos? Disconnect: [ULX] kicked from server: Don't use bad words fag User2: Good night Disconnect: [ULX] kicked from server: Don't use bad words fag User3: I need assistance admin plz Disconnect: [ULX] kicked from server: Don't use bad words fag User4: I need a little spice in my life :( Disconnect: [ULX] kicked from server: Don't use bad words fag
[QUOTE=FPtje;46812027]They can too if you ban them preventatively.[/QUOTE] Maybe I'll just make the Lua code log the sentence that they got banned for into a file, and if they apply, we see if they just made a mistake or not? [editline]28th December 2014[/editline] [QUOTE=Robotboy655;46811127]Since you are hiding the entire message, this is the only thing you need: [code]local bannedWords = { "po.st", } hook.Add( "PlayerSay", "blocked_words", function( ply, text, public ) local t = string.lower( text ) for id, str in pairs( bannedWords ) do if ( string.find( t, str ) ) then ULib:kickban(ply, nil, "Banned: Reason", "Admin" ) return "*** HIDDEN ***" end end end )[/code][/QUOTE] [code][ERROR] addons/ulib/lua/ulib/server/player.lua:154: attempt to call method 'SteamID' (a nil value) 1. kickban - addons/ulib/lua/ulib/server/player.lua:154 2. fn - addons/banwords/lua/autorun/sh_banwords.lua:9 3. unknown - addons/ulib/lua/ulib/shared/hook.lua:184[/code] :c
[QUOTE=tomhillepille;46812068]Maybe I'll just make the Lua code log the sentence that they got banned for into a file, and if they apply, we see if they just made a mistake or not? [editline]28th December 2014[/editline] [code][ERROR] addons/ulib/lua/ulib/server/player.lua:154: attempt to call method 'SteamID' (a nil value) 1. kickban - addons/ulib/lua/ulib/server/player.lua:154 2. fn - addons/banwords/lua/autorun/sh_banwords.lua:9 3. unknown - addons/ulib/lua/ulib/shared/hook.lua:184[/code] :c[/QUOTE] So you're banned until whining on some unpopular forum to be proven innocent. What heinous blasphemy do you want to censor anyway? Holocaust denying? Speaking badly of Best Korea? Saying "fuck" in chat?
[QUOTE=FPtje;46812417]So you're banned until whining on some unpopular forum to be proven innocent. What heinous blasphemy do you want to censor anyway? Holocaust denying? Speaking badly of Best Korea? Saying "fuck" in chat?[/QUOTE] Didn't you hear of 'Kawaii source banner'? Happened just 2 days ago, we lost around 5 players because of that. [editline]29th December 2014[/editline] I'll edit the code later, to only ban if its a po.st link, else the message gets censored.
So.. I still got the ban error and cant get it fixed. :c
Sorry, you need to Log In to post a reply to this thread.