Checking messageSents

Author Topic: Checking messageSents  (Read 2125 times)

Rky's does nothing but reports no console errors.

Quote
%badwordslist = "chese rhy ogm luwlut";//the badword
%replacewordslist = "Cheese rky omg lulwut";// the word to be said in the did you mean ____ ?
for (%i = 0; %i < getWordCount(%badwordslist) + 1; %i++)
{
%word = getword(%badwordslist, %i);
if(%word $= "" || %word $= " "){
%word = "PONY  PONYPONY PJJJbasicly not gonna set off anything unless you add this to the list which you wont because your not that stupid PONY PONYPONYPNJJJ";
}
for(%i2 = 0; %i2 < getWordCount(%text); %i2++)
{
%word2 = getword(%text,%i2);
if(strlwr(%word) $= strlwr(%word2)){
%foundbad = 1;
%badnum = %i;
}
}
}
if(%foundbad == 1){//if thems cant speelors
messageclient(%client,"","Did you mean"SPCgetword(%replacewordslist,%badnum)SPC"?");
return;
}quote]

Go ahead and add more words at the beggining(look at the comments for instructions)

Now it gives me a buffer overrun.


This may be a bump, but it's useful:

Code: [Select]
package WordCorrector {

function loadWords() {
   deleteVariables("$Pref::Server::Corrector::*");

   %file = new FileObject();
   %file.openForRead("./words.txt");
   while( !%file.isEOF() ) {
      %line = %file.readLine();
       $Pref::Server::Corrector::BadWord[ $Pref::Server::Corrector::BadWords++ ] = firstWord(%line);

       $Pref::Server::Corrector::CorrectWord[ $Pref::Server::Corrector::CorrectWords++ ] = restWords(%line);
   }
}

function serverCmdMessageSent(%client, %txt) {
   // Go ahead and send it regularly...
   Parent::serverCmdMessageSent(%client, %txt);

   // Loop through all of the words we wanna recognize:
   for(%j = 1; %j <= $Pref::Server::Corrector::BadWords; %j++) {
      %word = $Pref::Server::Corrector::BadWord[ %j ];

      // Did they say this word? Let's see:
      for(%i = 0; %i < getWordCount(%txt); %i++) {
         if( getWord(%txt, %i) $= %word ) {
            // They said something we recognized...
            %client.hasSaid[ %word ]++;

            //******************
            // What to do if they've said that word more than once?
            if( %client.hasSaid[ %word ] > 1 ) {
               %correctWord = $Pref::Server::Corrector::CorrectWord[ %j ];
               messageClient(%client, '', '\c2Do you mean, \c3%1\c2?', %correctWord);
            }
            //******************

         }
      }
   }
}

};

activatePackage(WordCorrector);

For example, in words.txt you have:

plausable plausible
yuo you
loel lol


If you say 'plausable' more than once, it tells you:
Did you mean, 'plausible'?

(Nothing happens if you respond... this is just a demo to show how to check words in peoples' messages.)
« Last Edit: November 07, 2007, 08:16:51 PM by exidyne »