Here's my code I wrote a year ago for this sort of thing, if you want to strip the good parts out.
function serverCmdForbidWords(%client,%player,%word)
{
%target = findclientbyname(%player);
for(%i=0; %i<getWordCount(%target.forbidWords); %i++)
{
if(getWord(%target.forbidWords,%i) $= %word)
{
%unforbid = true;
break;
}
}
if(%client.isSuperAdmin == 1 && %unforbid == false)
{
messageAll('','%1 \c2has forbid \c0%2\c2 of saying the word \c0\"%3\"\c2.',%client.name,%target.name,%word);
%target.forbidWords = %target.forbidWords SPC %word;
}
if(%client.isSuperAdmin == 1 && %unforbid == true)
{
messageAll('','%1 \c2has un-forbid \c0%2\c2 of saying the word \c0\"%3\"\c2.',%client.name,%target.name,%word);
%target.forbidWords = strReplace(%target.forbidWords,%word,"");
}
}
function serverCmdForbidLetters(%client,%player,%word)
{
%target = findclientbyname(%player);
for(%i=0; %i<getWordCount(%target.forbidLetters); %i++)
{
if(getWord(%target.forbidLetters,%i) $= %word)
{
%unforbid = true;
break;
}
}
if(%client.isSuperAdmin == 1 && %unforbid == false)
{
messageAll('','%1 \c2has forbid \c0%2\c2 of saying the character \c0\"%3\"\c2.',%client.name,%target.name,%word);
%target.forbidLetters = %target.forbidLetters SPC %word;
}
if(%client.isSuperAdmin == 1 && %unforbid == true)
{
messageAll('','%1 \c2has un-forbid \c0%2\c2 of saying the character \c0\"%3\"\c2.',%client.name,%target.name,%word);
%target.forbidLetters = strReplace(%target.forbidLetters,%word,"");
}
}
function serverCmdForbidSpeak(%client,%player)
{
if(%client.isSuperAdmin == 0){return;}
%target = findclientbyname(%player);
if(%target.isMuted != 1)
{
%target.isMuted = 1;
messageAll('','%1\c2 is now forbiden of speaking.',%target.name);
}
else
{
%target.isMuted = 0;
messageAll('','%1\c2 is no longer forbiden of speaking.',%target.name);
}
}
package ForbidWords
{
function serverCmdMessageSent(%client,%text)
{
if(%client.isMuted == 1)
{
messageClient(%client,'','\c2You are muted. Get out.');
return;
}
if(%client.forbidWords !$= "")
{
for(%i=0;%i<getWordCount(%text);%i++)
{
for(%k=0;%k<getWordCount(%client.forbidWords);%k++)
{
if(getWord(%text,%i) $= getWord(%client.forbidWords,%k))
{
messageClient(%client,'','You have been forbid of saying the word \c2\"%1\"\c0.',getWord(%text,%i));
return;
}
}
}
}
if(%client.forbidLetters !$= "")
{
for(%w=0; %w<strLen(%text); %w++)
{
%char = getSubStr(%text,%w,1);
for(%b=0; %b < getWordCount(%client.forbidLetters); %b++)
{
if(getWord(%client.forbidLetters,%b) $= %char)
{
messageClient(%client,'','You have been forbid of using the letter \c2\"%1\"\c0.',%char);
return;
}
}
}
}
Parent::serverCmdMessageSent(%client,%text);
}
};
activatePackage(ForbidWords);