This is based on William's tutorial. I found it a little unoptimized. So I did a little modification to it, and I also added in a replacing system. . First, in mod Globals, go add the following :
Code:
Public SwearArray() as string
Public ReplaceSwearArray() as string
.
Now, go to sub Main. At the top, declare the following variable :
Code:
Public SwearString as string
In the same sub, right after :
Code:
Call CheckTiles
add :
Code:
' Use the swear string to store the original swear words
SwearString = "ass,fuck,shit,bitch,damn,cunt,whore,piss"
SwearArray = Split(SwearString, ",")
' Use the swear string to store the replace swear words
SwearString = "donkey,luck,matress,lucky charms,cow,moo,jokeofweek,yellow"
ReplaceSwearArray = Split(SwearString, ",")
Now, to add in your own words, just add the swear word to the first string, and then add the replacement to the second string
Now, just add this function (a modified version of CheckMessage) :
Code:
Public Function CheckMessage(byval Msg As String) As String
Dim i As Long
CheckMessage = Msg
For i = 0 To UBound(SwearArray)
CheckMessage = Replace$(CheckMessage , SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare)
Next i
End Function
And there you go, you now have an optimized chat filter system which replaces swears with what you want them to. And, to quote william,:
Quote:
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