Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Feature] Client Swear Filter
#1
Originaly Created by Obsidian
Edited and refined by William

Difficulty: 1/5
Functionality: Works for all versions of MS.

Introduction
A standared simple client side swear filter that's added in 2-5minutes easily.

Client Side
Add this at the bottom of modGameLogic:
Code:
Public Function CheckMessage(byval Msg As String) As String
Dim kArray() As String
Dim Swears As String
Dim i As Integer
Dim SwearChar As String
  
    Swears = "ass,fuck,shit,bitch,damn,cunt,whore,piss,jesus,god"
    kArray = Split(Swears, ",")
  
    SwearChar = "*"
    
    For i = 0 To UBound(kArray)
        If InStr(LCase(Msg$), LCase(kArray(i))) Then
              Msg$ = Replace$(LCase(Msg$), LCase(kArray(i)), LCase(String(Len(kArray(i)), SwearChar)))
        End If
    Next i
    
    CheckMessage = Msg
End Function

Now search for all the different messages: adminmsg, saymsg, broadcastmsg, globalmsg, playermsg, mapmsg.

And do this on all of them:
Code:
Call GlobalMsg(ChatText)
Replace it with:
Code:
Call GlobalMsg(CheckMessage(ChatText))
And of course you shouldn't replace the saymsg call with a globalmsg call...

Good Luck And have Fun
Reply
#2
Yey, great! 25 points for me suckers :lol:
Reply
#3
How can I modify it so that there is more than one SwearChar that are Random. Such as: *!?@£$

Tried a few ways, but obviously would've failed.

EDIT: Managed to get it so it does random out of the characters "*!?@$":

Code:
Public Function CheckMessage(ByVal Msg As String) As String
Dim kArray() As String
Dim SwearCensor As String
Dim Swears As String
Dim i As Integer
Dim SwearChars As String
Dim SwearRnd As String
Dim strname As String
  
    Swears = "ass,fuck,shit,bitch,biatch,cunt,whore,piss,bastard,crap,nigger,pussy,penis,vagina,wank,masterbate"
    kArray = Split(Swears, ",")
  
    SwearChars = "*@!?$"
    SwearCensor = Len(SwearChars)
    SwearRnd = Int((SwearCensor * Rnd) + 1)
    
    strname = strname & Mid(SwearChars, SwearRnd, 1)
    
    For i = 0 To UBound(kArray)
        If InStr(LCase(Msg$), LCase(kArray(i))) Then
              Msg$ = Replace$(LCase(Msg$), LCase(kArray(i)), LCase(String(Len(kArray(i)), strname)))
        End If
    Next i
    
    CheckMessage = Msg
End Function

Still need to make it actually do like "*!?@$" instead of "@@@@@".
Reply
#4
Perfect
Reply
#5
wouldn't this cause all messages to go lower case?
Reply
#6
just wondering

what if they dont cuss
what if instead of saying

ass
they say i assisted that man the other day
will it do assisted
Reply
#7
Yes it would.
Reply
#8
thats bad
i mean lots of cuss words are in normal words
Assisted
Class
Bass
mass

umm im out but you get the point
Reply
#9
Just add a space around the word and fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)