Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chat Swear Filter
#1
Author: Obsidian
Difficulty: 1/5

This is a very basic swear filter.

:: SERVER SIDE ::
First, we need to setup the checks for the swears. Open modHandleData and find:
Code:
If LCase(Parse(0)) = "saymsg" Then
In this packet, after you see:
Code:
' Prevent hacking
        For i = 1 To Len(Msg)
              If Asc(Mid$(Msg, i, 1)) < 32 Or Asc(Mid$(Msg, i, 1)) > 126 Then
                  Call HackingAttempt(Index, "Say Text Modification")
                  Exit Sub
              End If
        Next i
Add:
Code:
Call CheckMessage(Index, Msg)

All you have to do is add that in the same exact spot for every type of chat that you want censored. (Admin, Global, Broadcast, Emote, etc.)

Now, at the bottom of modDatabase (or wherever, I just use Database) add this function:
Code:
Public Function CheckMessage(Index As Long, Msg As String)
Dim kArray() As String
Dim Swears As String
Dim i As Integer
Dim SwearChar As String
  
    Swears = "ass,fuck,shit,bitch,damn,"
    kArray = Split(Swears, ",")
    
    SwearChar = "*"
    
    ' Thanks to Classified For Help with the Full Word Replacement
    For i = 0 To UBound(kArray)
        If InStr(LCase(Msg$), LCase(kArray(i))) Then
              'Msg = Replace(Msg, kArray(i), SwearChar)
              Msg$ = Replace$(LCase(Msg$), LCase(kArray(i)), LCase(String(Len(kArray(i)), SwearChar)))
        End If
    Next i
End Function
Now, all you have to do is change the swear char (if you'd like) and then add to the swear list.

Note: The forum censors certain words, so be sure to replace whatever has been caught by the filter.

That's all!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)