//------------------------------------------------------ // Cleans out words specified in the banned word array // with the corresponding replacement word //------------------------------------------------------ //To clean chat messages change common/server/commands.cs // add: %text = cleanString(%text); // before: chatMessageTeam(%client, %client.team, '\c3%1: %2', %client.name, %text); $bannedWords[0] = "shit"; $replacementWord[0] = "shoot"; $bannedWords[1] = "damn"; $replacementWord[1] = "darn"; $bannedWords[2] = "bitch"; $replacementWord[2] = "sissy girl"; $bannedWords[3] = "asshole"; $replacementWord[3] = "bad man"; $numBannedWords = 4; function cleanString(%string) { for(%i=0; %i<$numBannedWords; %i++) { %string = Strreplace( %string, $bannedWords[%i], $replacementWord[%i] ); } return %string; } //banned word file should have one bannedWord, replacementWord //pair per line seperated by a comma //ex: // damn, darn // crap, crud function readBannedWords(%bannedWordFile) { %file = new FileObject(); if( !%file.openForRead(%bannedWordFile) ) { echo("file:" SPC %bannedWordFile SPC "not valid"); return; } %i = 0; while( !%file.isEOF() ) { %line = %file.readLine(); %bWord = ""; %stringLeft = nextToken(%line, bWord, ","); %bWord = Trim(%bWord); %rWord = Trim(%stringLeft); $bannedWords[%i] = %bWord; $replacementWord[%i] = %rWord; %i++; } $numBannedWords = %i; }