Here's a censorship NPC weapon I am releasing for the good of Graal. Most of the banned words are removed so as to not break forum rules. If you want the full script, including humorous exceptions, please email me.
EDIT: Function you() doesn't work correctly as it removes all quotes. It is remarked until I can devise a better solution for fixing these nuisances.
NPC Code:
//by Jeff (email: [email protected])
//to censor a word add it to the this.restrictedwords list
//Use at will so long as credits are intact
//#CLIENTSIDE
function you(){ //Borrowed from Kaimetsu. I am lazy.
//Function to check spelling of the words "you" and "are"
/* tokenize #c; for (i=0;i<tokenscount;i++) {
if(strequals(#t(i),u)){
setstring local.chat,#s(local.chat)you#K(160);
}else if(strequals(#t(i),r)){
setstring local.chat,#s(local.chat)are#K(160);
}else{setstring local.chat,#s(local.chat)#t(i)#K(160);}
}
setplayerprop #c,#s(local.chat); setstring local.chat,;*/
}
function generateCensor(){
//Exceptions to asterisking
setstring this.censor,;
if(strequals(#I(this.restrictedwords,i),plz)){
setstring this.censor,please;
}else if(strequals(#I(this.restrictedwords,i),pls)){
setstring this.censor,please;
}else{
//Asterisk generation
for(j=0;j<strlen(#I(this.restrictedwords,i));j++){ setstring this.censor,#s(this.censor)*;}
}
}
if (playerchats || created || playerenters) {
this.u=0;
setstring this.restrictedwords,ghey,plz,pls;//censored words
for(i=0;i<sarraylen(this.restrictedwords);i++){ //run through restricted words
if(indexof(#I(this.restrictedwords,i),#c)>=0){ //check for censored words
generateCensor(); //generate censor
setstring this.newchatstring,#e(0,indexof(#I(this.restricted words,i),#c),#c)#s(this.censor)#e(indexof(#I(this. restrictedwords,i),#c)+strlen(#I(this.restrictedwo rds,i)),-1,#c);
setplayerprop #c,#s(this.newchatstring);
addstring client.message,The word "#I(this.restrictedwords,i)" is not permitted on this server.;
i-=2;
}//end check for censored words
}//end run through restricted words
you(); //fix you
} //end playerchats
Again, put this on your server if you want. Hey, I even encourage you.