Mirage Source http://web.miragesource.net/forums/ |
|
Chat Swear Filter http://web.miragesource.net/forums/viewtopic.php?f=210&t=53 |
Page 1 of 1 |
Author: | Tutorial Bot [ Thu Jun 01, 2006 9:29 pm ] |
Post subject: | Chat Swear Filter |
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) Now, all you have to do is change the swear char (if you'd like) and then add to the swear list.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 Note: The forum censors certain words, so be sure to replace whatever has been caught by the filter. That's all! |
Author: | Belier13 [ Tue Jun 13, 2006 4:07 pm ] |
Post subject: | |
Well, I changed it a bit, and I thought I could share Code: Public Function CheckMessage(Msg As String)
Dim SwearSplit() As String Dim SwearReplaceSplit() As String Dim Swears As String Dim SwearReplace As String Dim i As Integer Swears = "ass,fuck,shit,bitch," SwearReplace = "***,f**k,s**t, b****," SwearSplit = Split(Swears, ",") SwearReplaceSplit = Split(SwearReplace, ",") For i = 0 To UBound(SwearSplit) If InStr(LCase(Msg$), LCase(SwearSplit(i))) Then Msg$ = Replace$(LCase(Msg$), LCase(SwearSplit(i)), LCase(SwearReplaceSplit(i)), 1) End If Next i End Function What I did is removing the Useless Byval Index as long and exept of remplacing whole insult by ***, you can change to whatever you want |
Author: | Obsidian [ Tue Jun 13, 2006 7:13 pm ] |
Post subject: | |
that's not a bad little addition i originally wrote this code for an engine, so it wouldn't make much sense having two different (or even and extra set of info) for a txt or ini file. The engine just allows you to add different swears, and select the swear character, which by default is * |
Author: | Bradyok [ Wed Jun 14, 2006 11:09 pm ] |
Post subject: | |
Thanks for sharing it and damn.. I was looking for the command to split a bunch of stuff divided by ,'s so this also helped me with that. |
Author: | Tosuxo [ Thu Jun 15, 2006 8:24 pm ] |
Post subject: | |
pretty nice tutorial that, thanks p.s. Tosuxo is back at Mirage Source!! WOOO!!! |
Author: | Robin [ Fri Jun 23, 2006 6:08 pm ] |
Post subject: | |
Im not really sure, but wouldn't that change the entire thing into lowercase? |
Author: | Belier13 [ Fri Jun 23, 2006 8:22 pm ] |
Post subject: | |
^ Just checked, it does.. whata crap |
Author: | Tosuxo [ Fri Jun 23, 2006 8:44 pm ] |
Post subject: | |
yeh, but there are few cases when upper-case is needed... i can't think of any right now... but all the same, it would be good if someone could fix this problem... if that's possible... :S |
Author: | Robin [ Fri Jun 23, 2006 9:00 pm ] |
Post subject: | |
I think this might work: Msg = Replace(Msg, kArray(i), String(Len(kArray(i))), SwearChar) (might need to change the syntax, the '(' etc. i don't have visual basic with me. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |