ULX

Author Topic: Swear Blocker?  (Read 6681 times)

0 Members and 2 Guests are viewing this topic.

Offline Silver

  • Newbie
  • *
  • Posts: 8
  • Karma: 1
Swear Blocker?
« on: August 01, 2006, 06:55:47 PM »
I'm not sure if this was released yet but I would like a swear blocker because little kids sometimes come to my server. And people ALWAYS swear. I don't think the little kids should have to deal with these kinds of bad examples from other players. Sometimes little kids might ignore it, but others don't but they will end up copying the example that was given. Say for instance, the F-Word

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Swear Blocker?
« Reply #1 on: August 06, 2006, 02:28:01 PM »
Good idea!
Would you totally stop everything they said from coming across?
Or would you censor out just that word?
I could see a table of words, and what to replace them with.
This could be edited for multiple spellngs. , SH1T 5H1T, etc etc etc.
You know as soon as someone finds out there is a censor, they start looking for creative ways around it.
Give a warning if language was detected?
Automatically kick/ban?
Automatically 'gimp' them on 2nd try, allowing them to stay but not say anything?
The new Ulib.db functions might be good for tracking repeat offenders if you didn't want to ban them straight out.
Personally, I'd perm ban, but, thats just my iron fist.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Mank

  • Full Member
  • ***
  • Posts: 209
  • Karma: 9
    • Ulysses Mod!
Re: Swear Blocker?
« Reply #2 on: September 04, 2006, 03:33:10 PM »
Thing is, no need to block other alternatives, if you're that desperate, you'll work out how to say the word, just block the main word, and people will just say something else.  Though, this game is a 15 rated game, so small kids shouldn't be playing it anyway, but it's good to do I think.
If you doubt your powers you bring powers to your doubts.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Swear Blocker?
« Reply #3 on: September 04, 2006, 05:08:01 PM »
I'm currently working on a swear blocking script.  ;)

The biggest problem is I'm worried it will take too much CPU power to do a comprehensive check. It's easy enough to look for basic swears, but looking for more complex ones where people might use "/-\" as an A is a lot more difficult. If lua had a full regex library, it might be easier...

Anyways, I'm thinkng of implementing a random comprehensive check if the CPU usage is too high. This means that it would only check a string comprehensively in one out of say 10 user's says. Once it does find someone swearing, it could flag the user as 'problematic' and submit them to a comprehensive check 100% of the time after that.

Guess I got off topic there :P
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Swear Blocker?
« Reply #4 on: September 04, 2006, 05:12:17 PM »
True Mank, most will always challenge and try to work around by using a secondary word.
Even though Hl2 is a 15+ game, most of the people I see online everyday are younger.
It doesn't bother me that so many are younger, but it does bother me many swear/act immature unchecked, without parental guidance.
Personally, I'm one to give a second chance. Many use that language out of habit, more so than on purpose. If one were to do it on purpose after being warned (through message/kick or both), that is the point they would try to outsmart the script using a separate spelling, and I think a ban at that point would get the point across.
 Perhaps when I find time, I'll work on creating an anti-swear script for Ulib.
I've seen bits and pieces of code at facepunch forums. They're might be one there already.

Megiddo, you posted while I was writing above.
I'll let the expert coder handle it then :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Terminal58

  • Newbie
  • *
  • Posts: 41
  • Karma: 1
Re: Swear Blocker?
« Reply #5 on: September 06, 2006, 02:06:38 PM »
Code: [Select]
function eventPlayerSay(userid, strText, bTeam) --My custom curse word blocker
BadWords = {"", "", "omg", "lol", "rofl", "brb"} --well here are our bad words
GoodWords = {"****", "****", "oh my god", "laugh out load", "rolling on floor laughing", "be right back"} --and he's what we will replace them with
local message = string.lower(strText); --this will be our message except all in lower case
local Indent = 0;
local StartLoc; --Starting location of the bad word
local EndLoc; --end
local StrInMsg; --the actual bad word in the "real" message, not the lower case one
local size = table.getn(BadWords)
for i=1, size do --we're going to check every word in the bad words list
StartLoc = string.find(message, BadWords[i], Indent) --we need to use the lower case message so that it's not case sensitive
while StartLoc ~= nil do --while we have a bad word
EndLoc = (string.len(BadWords[i])+StartLoc)-1 --we can find the end of the bad word if we know what word it is
_Msg(StartLoc)
_Msg(EndLoc)
StrInMsg = string.sub(strText, StartLoc, EndLoc) --this is the actual bad word in the real message with the case
strText = string.gsub(strText, StrInMsg, GoodWords[i]) --we're going to replace this bad word with a good one
message = string.lower(strText) --make sure we update the lower case message
Indent = EndLoc + 1 -- add our indent, which isn't really needed but i guess it could make the script go a bit faster
local firstLetter=string.upper(string.sub(strText,1,1));
local restOfString=string.sub(strText,2,-1);
lastmessage = firstLetter..restOfString;
if (Indent >= string.len(strText)) then  --make sure we haven't over run the length of the message, if we have, we're done
break
end
StartLoc = string.find(message, BadWords[i], Indent) -- make sure there is still a bad word in there
end
Indent = 0  --reset our indent for the next bad word
end
if ( bTeam == false ) then --If the message is for everyone, just send it once to everyone
  _GModText_Start( "Default" ); --Just standard style
  _GModText_SetColor( 255, 255, 255, 255 ); --Color: RGB A -> White, no transparency (Alpha 255)
  _GModText_SetTime( 5, 1, 1 ); --How long it stays, and the fading times
  _GModText_SetEntityOffset( vector3( 0, 0, 35 ) ); --Messages appear 35 Units above Players
  _GModText_SetEntity( userid ); --Entity/Player the message will follow
  _GModText_SetText( strText ); --Set the message
  _GModText_Send( 0, 50+userid ); --Send it ( 0 => send to everyone )
 else
  local pteam = _PlayerInfo(userid,"team"); --Get the team of the player, who sent the chat message
  for i=1, _MaxPlayers() do
   if ( _PlayerInfo(i,"team") == pteam and i ~= userid ) then --now only send it to teammates
    _GModText_Start( "Default" ); --Just standard style
    _GModText_SetColor( 255, 255, 255, 255 ); --Color: RGB A -> White, no transparency (Alpha 255)
    _GModText_SetTime( 2, 0, 0.5 ); --How long it stays, and the fading times
    _GModText_SetEntityOffset( vector3( 0, 0, 35 ) ); --Messages appear 35 Units above Players
    _GModText_SetEntity( userid ); --Entity/Player the message will follow
    _GModText_SetText( strText ); --Set the message
    _GModText_Send( i, 50+userid ); --Send it ( i => send it to the current i => those are only teammates now, since we filter any other out )
   end
  end
 end
return ""..strText.." ";  --give back the text except with the replaced bad words
end
Not a Ulib or ULX script not sure if it works with it Ulib admin isn't working for me.

EDIT

Fixed code sorry its in my complete one that I use for my server so it has some extras.
« Last Edit: September 06, 2006, 06:51:25 PM by Terminal58 »