I did something similar a while ago.
The below code was created on the spot by me in 2 seconds, I did not test it, do not expect it to be perfect.
It is rather a mess, and does many more variable assignments than it needs to due to the fact that I added many comments and torque only allows comments
code//on
code//a
code//line
code//by
code//line
code//basis
code/*instead*/code/*of*/code/*working*/code/*as*/code/*it*/code/*should*/morecode
However it should still work.
if(isPackage(iDidThisDifferentlyAWhileAgoOnMyServer));
deactivatePackage(iDidThisDifferentlyAWhileAgoOnMyServer);
package iDidThisDifferentlyAWhileAgoOnMyServer {
//Ten words should be enough for a simple action. (That's what I imagine people using /me for.)
function serverCmdMe(%client, %wrd1, %wrd2, %wrd3, %wrd4, %wrd5, %wrd6, %wrd7, %wrd8, %wrd9, %wrd10) {
//build a string from our arguments
for(%i = 1; %i <= 10; %i++)
%str = %str SPC %wrd[%i];
//collapse two spaces to one.
while(strPos(%str, " "))
%str = strReplace(%str, " ", " ");
%str = stripColorCodes(%str); //strip \c# color codes
%str = stripMLControlChars(%str); //strip <torque:ml> tags
%str = reinventionOfTheWheel(%str); //reinvent the wheel with the etard filter.
%str = trim(%str); //strip leading and trailing spaces
announce("*" @ %client.getPlayerName() SPC %str);
}
};
activatePackage(iDidThisDifferentlyAWhileAgoOnMyServer);
//This is an etarded mess, the BL etard filter already does this, I just cant figure out how to call it.
function reinventionOfTheWheel(%string) {
//We make a localized version of the etard list cause otherwise
//nextToken would remove all the words from this list.
%etardList = $pref::server::etardList;
while(%etardList !$= "") {
%etardList = nextToken(%etardList, "etardWord", ",");
%string = strReplace(%string, %etardWord, getCensor(%etardWord));
}
return %string;
}
Now it's off to dinner for me.