| Mirage Source http://web.miragesource.net/forums/ |
|
| Optional Censoring http://web.miragesource.net/forums/viewtopic.php?f=183&t=4373 |
Page 1 of 57 |
| Author: | GIAKEN [ Fri Sep 19, 2008 7:51 pm ] |
| Post subject: | Optional Censoring |
Difficulty: ?/5 - It's not a direct C&P tutorial. I tried to explain things, but I don't have a copy of MS4 on my laptop currently so this will try to explain things as best as possible. < CLIENT SIDE > Make a new check box object on frmMirage. This will let players turn censoring on or off for themselves. Now double click the check box and add this: Code: Call SendData("censor" & END_CHAR) Now where the packets are checked, add this: Code: If Parse$(0) = "censor" Then If Val(Parse$(1)) = 3 Then frmMirage.chkCensor.Enabled = False frmMirage.chkCensor.Value = 0 Else If frmMirage.chkCensor.Enabled = False Then frmMirage.chkCensor.Enabled = True frmMirage.chkCensor.Value = Val(Parse$(1)) End If Exit Sub End If < SERVER SIDE > Find where the player is logged in. It should be something like "LoadPlayer(Index, Name)". Add this to that section: Code: If CENSOR_ON = 1 Then Call SendDataTo(Index, "censor" & SEP_CHAR & Player(Index).Censor & END_CHAR) Else Call SendDataTo(Index, "censor" & SEP_CHAR & 3 & END_CHAR) End If Now find where all the packets are handled in the server. Add this to the list of Case's: Code: Case "censor" If CENSOR_ON = 1 Then Player(Index).Censor = Not Player(Index).Censor Call SendDataTo(Index, "censor" & SEP_CHAR & Player(Index).Censor & END_CHAR) Else Call SendDataTo(Index, "censor" & SEP_CHAR & 3 & END_CHAR) End If Exit Sub Open the Data.ini file and under MAX add: CENSOR=1 Now here's the magic function, in modGeneral (or wherever) add this: Code: Public Function CensorShip(ByVal Index As Long, ByVal Sentence As String) As String Dim I As Long CensorShip = Sentence If CENSOR_ON = 1 Then If Player(Index).Censor = 1 Then For I = 1 To TOTAL_CENSOR CensorShip = Replace$(Sentence, Censor(I).Find, Censor(I).Replace, , , vbTextCompare) If CensorShip <> Sentence Then Sentence = CensorShip Next I End If End If End Function Add this at the top of a module: Code: ' Censoring data Public CENSOR_ON As Byte Public TOTAL_CENSOR As Long Type CensorRec Find As String Replace As String End Type Public Censor() As CensorRec Find where the server is initialized (ServerInit?) and add this: Code: CENSOR_ON = GetVar(App.Path & "\Data.ini", "CONFIG", "CENSOR") If CENSOR_ON <> 0 Then I = 1 Do If GetVar(App.Path & "\Censor.ini", "CENSOR" & I, "Find") = "" Then Exit Do I = I + 1 Loop TOTAL_CENSOR = I - 1 ReDim Censor(1 To TOTAL_CENSOR) For I = 1 To TOTAL_CENSOR Censor(I).Find = GetVar(App.Path & "\Censor.ini", "CENSOR" & I, "Find") Censor(I).Replace = GetVar(App.Path & "\Censor.ini", "CENSOR" & I, "Replace") Next I End If This will be the piece of data in the player's collection that will tell if they want to see censors. In "PlayerRec" add this: Code: Censor As Byte Now in SavePlayer, add this after it sets the player's password: Code: Call PutVar(FileName, "GENERAL", "Censor", Trim$(Player(Index).Censor)) Now in LoadPlayer, add this after it gets the player's password: Code: Player(Index).Censor = Val(GetVar(FileName, "GENERAL", "Censor")) I'm not exactly sure where all the chat is handled, because this wasn't made for MS4. So wherever the server sends the chat to the client, you need to wrap the variable with the CensorShip function. Example: In MapMsg you'll see a loop and something like "Packet = "mapmsg" & SEP_CHAR & Msg ..." Change the Msg to: Censorship(I, Msg). Since we have each player able to turn the censoring on or off, we have to go directly inside the subs that send out the message so that it can use the function in the loop. Also make a new Censor.ini file where the Server.exe is and paste this inside the file: Code: [CENSOR1]
Find=fuck Replace=**** [CENSOR2] Find=bitch Replace=***** [CENSOR3] Find=shit Replace=**** [CENSOR4] Find=cock Replace=**** [CENSOR5] Find=dick Replace=**** [CENSOR6] Find=pussy Replace=***** [CENSOR7] Find=ass Replace=*** [CENSOR8] Find=cunt Replace=**** [CENSOR9] Find=twat Replace=**** [CENSOR10] Find=whore Replace=***** |
|
| Author: | GIAKEN [ Fri Sep 19, 2008 8:07 pm ] |
| Post subject: | Re: Optional Censoring |
Just saw a problem and fixed it I was looking it over and noticed that it would only censor one word. So I changed: Code: If CensorShip <> Sentence Then Exit For To: Code: If CensorShip <> Sentence Then Sentence = CensorShip
|
|
| Author: | Robin [ Fri Sep 19, 2008 8:18 pm ] |
| Post subject: | Re: Optional Censoring |
Faaail. |
|
| Author: | GIAKEN [ Fri Sep 19, 2008 8:44 pm ] |
| Post subject: | Re: Optional Censoring |
Yeah that's true...I like to over complicating things |
|
| Author: | GIAKEN [ Fri Sep 19, 2008 9:21 pm ] |
| Post subject: | Re: Optional Censoring |
Well I just tested the function against: fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckshitshitshitshitshitshitbitchbitchbitchbitchbitch And turned censor on and off and both returned 0 ms. |
|
| Author: | GIAKEN [ Fri Sep 19, 2008 9:29 pm ] |
| Post subject: | Re: Optional Censoring |
The actual function CensorShip (since that's all that the server requires extra work) from when it starts to when it ends. Time = GetTickCount, MsgBox GetTickCount - Time |
|
| Author: | Robin [ Fri Sep 19, 2008 9:32 pm ] |
| Post subject: | Re: Optional Censoring |
GIAKEN wrote: The actual function CensorShip (since that's all that the server requires extra work) from when it starts to when it ends. Time = GetTickCount, MsgBox GetTickCount - Time Awww, you already know your game is gonna fail so hard you think only one person is going to be talking at once? Set up 80 connections, all spamming it |
|
| Author: | GIAKEN [ Fri Sep 19, 2008 9:36 pm ] |
| Post subject: | Re: Optional Censoring |
Well if each time they enter a message that takes the server less than a millisecond to process the censoring with then I doubt they would be able to even get the server to take a full second of processing unless they can send more than 1000 messages... |
|
| Author: | Doomy [ Fri Sep 19, 2008 9:46 pm ] |
| Post subject: | Re: Optional Censoring |
wouldnt this be good if you make it add 1 to the ini with thier name and if it is over a certain number it mutes them"?" |
|
| Author: | GIAKEN [ Fri Sep 19, 2008 9:48 pm ] |
| Post subject: | Re: Optional Censoring |
doomteam1 wrote: wouldnt this be good if you make it add 1 to the ini with thier name and if it is over a certain number it mutes them"?" No because the point is to let them choose if they want words to be censored or not. |
|
| Author: | wanai [ Mon Dec 27, 2021 7:10 pm ] |
| Post subject: | Re: Optional Censoring |
XIII |
|
| Author: | wanai [ Mon Dec 27, 2021 7:11 pm ] |
| Post subject: | Re: Optional Censoring |
49.6 |
|
| Author: | wanai [ Mon Dec 27, 2021 7:12 pm ] |
| Post subject: | Re: Optional Censoring |
Bett |
|
| Author: | wanai [ Mon Dec 27, 2021 7:13 pm ] |
| Post subject: | Re: Optional Censoring |
Bett |
|
| Author: | wanai [ Mon Dec 27, 2021 7:14 pm ] |
| Post subject: | Re: Optional Censoring |
Blaw |
|
| Author: | wanai [ Mon Dec 27, 2021 7:15 pm ] |
| Post subject: | Re: Optional Censoring |
Paul |
|
| Author: | wanai [ Mon Dec 27, 2021 7:17 pm ] |
| Post subject: | Re: Optional Censoring |
Inke |
|
| Author: | wanai [ Mon Dec 27, 2021 7:18 pm ] |
| Post subject: | Re: Optional Censoring |
Dona |
|
| Author: | wanai [ Mon Dec 27, 2021 7:19 pm ] |
| Post subject: | Re: Optional Censoring |
Alis |
|
| Author: | wanai [ Mon Dec 27, 2021 7:20 pm ] |
| Post subject: | Re: Optional Censoring |
Vive |
|
| Author: | wanai [ Mon Dec 27, 2021 7:21 pm ] |
| Post subject: | Re: Optional Censoring |
Nina |
|
| Author: | wanai [ Mon Dec 27, 2021 7:22 pm ] |
| Post subject: | Re: Optional Censoring |
Prov |
|
| Author: | wanai [ Mon Dec 27, 2021 7:23 pm ] |
| Post subject: | Re: Optional Censoring |
Wisa |
|
| Author: | wanai [ Mon Dec 27, 2021 7:24 pm ] |
| Post subject: | Re: Optional Censoring |
Ster |
|
| Page 1 of 57 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|