I only test this mod in local. But in theory it should run on server also.
If you install only on client yourself, this only works locally.
If you install it on server, it should influence the whole chat. I guess?
Now those words you don’t like will be replaced with a “*”.(You can change the “*” into anything you like.)
Add their names in the mod.json.
If you use this with a server, may you can add their UIDs. (I don’t know how to get the UID in Client, so this feature not works in local user.)
It offers 3 modes: Replace| Block| Both
Replace Replace the dirty words with placeholder.
Block Block players away from your char.(Their messages are still shown in other players’ chats.)
Both Replace and Block
Use [Space] to separate the keywords like: "dirty1 dirty2 dirty3"
// use [Space] to sep
"ConVars": [
{
"Name": "l1nexus_keyword_chatfilter_keywords",
"DefaultValue": ""
},
{
"Name": "l1nexus_keyword_chatfilter_blacklistPlayername",
"DefaultValue": ""
},
{
"Name": "l1nexus_keyword_chatfilter_blacklistPlayerUID",
"DefaultValue": ""
},
{
"Name": "l1nexus_keyword_chatfilter_mode",
// Replace | Block | Both
"DefaultValue": "Both"
},
{
"Name": "l1nexus_keyword_chatfilter_replaceHolder",
"DefaultValue": "*"
}
]
I noticed that there is a StringReplace function existed. But I failed to figure out the parameters, so I did mine.
// return start index of a substring in the string
// -1, means not found.
int function SearchString(string targetString, string search)
{
int index = -1
int flag = 1
if (targetString.len() < search.len()) return -1
if (targetString == search) return 0
for(int i; i < targetString.len() - search.len() + 1; i++)
{
if (targetString[i] != search[0]) continue
for(int j = 0; j < search.len(); j++)
{
if (targetString[i+j] != search[j])
{
flag = 0
}
}
if (flag)
index = i
}
return index
}
string function ReplaceString(string targetString, string oldString, string newString, bool replaceAll, bool ignoreCaps)
{
if (targetString.len() < oldString.len()) return targetString
if (targetString == oldString) return newString
int index = -1
string searchString = targetString
if (ignoreCaps)
{
searchString = targetString.toupper()
oldString = oldString.toupper()
}
index = SearchString(searchString, oldString)
print(searchString + " " + oldString + " " + newString + " index "+ index)
while(index != -1)
{
if (index == 0)
{
targetString = newString + targetString.slice(oldString.len(), targetString.len())
}
else
{
targetString = targetString.slice(0, index) + newString + targetString.slice(index + oldString.len(), targetString.len())
}
// replace once
if (!replaceAll)
break
// prepare next search
searchString = targetString.toupper()
index = SearchString(searchString, oldString)
}
return targetString
}
These 2 functions are globalized. You can use them with this mod, or just copy the code.