Mirage Source http://www.miragesource.net/forums/ |
|
Client Swear Filter With Replaces http://www.miragesource.net/forums/viewtopic.php?f=183&t=4431 |
Page 1 of 74 |
Author: | JokeofWeek [ Tue Sep 23, 2008 2:47 am ] |
Post subject: | Client Swear Filter With Replaces |
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 |
Author: | GIAKEN [ Tue Sep 23, 2008 2:56 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Unfortunately, it won't work...it will only replace the last swear word in the string. Like this: Msg = "shit whore fuck bitch" for example... CheckMessage = "**** whore fuck bitch" but Msg is still the same so it will look for the second swear...so then CheckMessage = "shit ***** fuck bitch" and then Msg will still equal the same thing...so you do: Code: Public Function CheckMessage(byval Msg As String) As String Dim i As Long For i = 0 To UBound(SwearArray) CheckMessage = Replace$(Msg, SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare) If CheckMessage <> Msg Then Msg = CheckMessage Next i End Function Also changed i to a Long because it's the fastest type to use for loops. |
Author: | JokeofWeek [ Tue Sep 23, 2008 2:58 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
GIAKEN wrote: Unfortunately, it won't work...it will only replace the last swear word in the string. Like this: Msg = "shit whore fuck bitch" for example... CheckMessage = "**** whore fuck bitch" but Msg is still the same so it will look for the second swear...so then CheckMessage = "shit ***** fuck bitch" and then Msg will still equal the same thing...so you do: Code: Public Function CheckMessage(byval Msg As String) As String Dim i As Long For i = 0 To UBound(SwearArray) CheckMessage = Replace$(Msg, SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare) If CheckMessage <> Msg Then Msg = CheckMessage Next i End Function Also changed i to a Long because it's the fastest type to use for loops. Ah true, thanks for that first fix, hadn't thought of that. And yeah, I thought of using I as a long for the loop, I'll probably do that . Thanks for that mate |
Author: | wanai [ Wed Dec 29, 2021 12:19 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Econ |
Author: | wanai [ Wed Dec 29, 2021 12:20 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
55.2 |
Author: | wanai [ Wed Dec 29, 2021 12:21 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Bett |
Author: | wanai [ Wed Dec 29, 2021 12:22 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Bett |
Author: | wanai [ Wed Dec 29, 2021 12:24 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Side |
Author: | wanai [ Wed Dec 29, 2021 12:25 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Lieb |
Author: | wanai [ Wed Dec 29, 2021 12:26 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Walk |
Author: | wanai [ Wed Dec 29, 2021 12:27 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Jorg |
Author: | wanai [ Wed Dec 29, 2021 12:28 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Juli |
Author: | wanai [ Wed Dec 29, 2021 12:29 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Fair |
Author: | wanai [ Wed Dec 29, 2021 12:30 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Bigb |
Author: | wanai [ Wed Dec 29, 2021 12:32 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Prov |
Author: | wanai [ Wed Dec 29, 2021 12:33 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Zero |
Author: | wanai [ Wed Dec 29, 2021 12:34 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Weee |
Author: | wanai [ Wed Dec 29, 2021 12:35 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Jame |
Author: | wanai [ Wed Dec 29, 2021 12:36 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Xerx |
Author: | wanai [ Wed Dec 29, 2021 12:37 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Dine |
Author: | wanai [ Wed Dec 29, 2021 12:38 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Duns |
Author: | wanai [ Wed Dec 29, 2021 12:39 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Full |
Author: | wanai [ Wed Dec 29, 2021 12:41 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Kath |
Author: | wanai [ Wed Dec 29, 2021 12:42 am ] |
Post subject: | Re: Client Swear Filter With Replaces |
Plus |
Page 1 of 74 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |