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=*****
_________________
Nean wrote:
Yes harold. Give it to me.