Mirage Engine
[Feature] Client Swear Filter - Printable Version

+- Mirage Engine (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: [Feature] Client Swear Filter (/showthread.php?tid=2142)



[Feature] Client Swear Filter - William - 20-09-2008

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


Re: [Feature] Client Swear Filter - William - 20-09-2008

Yey, great! 25 points for me suckers :lol:


Re: [Feature] Client Swear Filter - Mattyw - 21-09-2008

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 "@@@@@".


Re: [Feature] Client Swear Filter - mustorze - 21-09-2008

Perfect


Re: [Feature] Client Swear Filter - Tosuxo - 04-11-2008

wouldn't this cause all messages to go lower case?


Re: [Feature] Client Swear Filter - Doomy - 04-11-2008

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


Re: [Feature] Client Swear Filter - GIAKEN - 04-11-2008

Yes it would.


Re: [Feature] Client Swear Filter - Doomy - 04-11-2008

thats bad
i mean lots of cuss words are in normal words
Assisted
Class
Bass
mass

umm im out but you get the point


Re: [Feature] Client Swear Filter - GIAKEN - 04-11-2008

Just add a space around the word and fixed.