With all the new servers, I am sure there is at least one that did not think about making a profanity filter. To save everyone some time, here is the one I made for Tribulation. A caveat: put longer swears first unless you don't want the whole word ***ed. Example, listing just the f-bomb would change what Oedipus was into mother****er, or listing an alternative name for a donkey would change another word for part of your posterior to ***hole. So put the longer words first if you don't like this solution. Without further ado, the script:
[edit]I realized that the original script had problems with words like assassin, so I changed it to check whole words only. Sorry, it means a much longer list of obscenities. On the bright side, it means you don't need to worry about putting longer swears first. The other option is to make a list of exception words, which I will post according to public demand[/edit]
[edit2]Fixed a bug where mASSive a** (and other such phrases)was not censored. [/edit2]
NPC Code:
// NPC made by gilt
//#CLIENTSIDE
if (created) {
setstring this.filter,your,words,here;
}
if (playerchats)
{
tokenize #c;
this.offset=0;
for (this.j=0;this.j<tokenscount;this.j++)
{
for (this.i=0;this.i<sarraylen(this.filter);this.i++)
{
this.index=indexof(#I(this.filter,this.i),#e(this. offset,-1,#c));
if (this.index!=-1&&(strequals(#e(this.index-1+this.offset,1,#c), )||this.index+this.offset==0)&&(strequals(#e(this. index+this.offset+strlen(#I(this.filter,this.i)),1 ,#c), )) )
{
setstring this.remainder,#e(this.index+this.offset+strlen(#I (this.filter,this.i)),-1,#c);
for (this.k=0;this.k<strlen(#I(this.filter,this.i));th is.k++)
{
setplayerprop #c,#e(0,this.index+this.offset+this.k,#c)*;
}
setplayerprop #c,#c#s(this.remainder);
}
}
this.offset+=strlen(#t(this.j))+1;
}
}