Author Topic: Enabling a chatbot  (Read 507 times)

I created a chatbot named FancyBot, and everything looks okay.

The only problem is activating it. If I try to activate it using activatePackage(FancyBot); but it says the package cant be found.

Great.
Show us your code so we can help you.

Quote
package FancyBot
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
      Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
         if(isObject(FancyBot))
          {
            switch$(%msg)
               {

            case "Good":
            commandToServer('messageSent', "FancyBot: Very genious, old chap."); break;

            case "lol":
               commandToServer('messageSent', "FancyBot: I do not laugh, I am too fancy."); break;

            case "derp":
               commandToServer('messageSent', "FancyBot: You sir, are a 'herp' and 'derp'."); break;

            case "wtf":
               commandToServer('messageSent', "FancyBot: What is this foolishness?"); break;

            case "FancyBot":
               commandToServer('messageSent', "FancyBot: Yes, What do you want?"); break;

            case "Cool":
               commandToServer('messageSent', "FancyBot: Indubitably."); break;

            case "idk":
               commandToServer('messageSent', "FancyBot: Not knowing? How unfancy."); break;

            case "What?":
               commandToServer('messageSent', "FancyBot: You heard the man."); break;

            case "Wait":
               commandToServer('messageSent', "FancyBot: What is the problem, sir?"); break;

            case "shut up":
               commandToServer('messageSent', "FancyBot: Why do you not try, sir?"); break;

            case "no you shut up":
               commandToServer('messageSent', "FancyBot: No."); break;

            case "afk":
               commandToServer('messageSent', "FancyBot: Quick, he is leaving! Get him!"); break;

            case "cake":
               commandToServer('messageSent', "FancyBot: There is no cake, chap."); break;

            case "That makes FancyBot sad":
            commandToServer('messageSent', "FancyBot: *cries*"); break;

            case "who are you?":
               commandToServer('messageSent', "FancyBot: I don't really know.."); break;

            case "youre stupid":
            commandToServer('messageSent', "FancyBot: Are you talking to me.. or"); break;

            case "your mom":
               commandToServer('messageSent', "FancyBot: I'm an gentleman orphan."); break;

            case "bye":
               commandToServer('messageSent', "FancyBot: Bye."); break;

            case "gtg":
               commandToServer('messageSent', "FancyBot: Cant the leaving wait, chap?"); break;

            case "FancyBot Off":
               commandToServer('messagesent', "FancyBot: Well, a gentlemen needs hiss sleep."); break;
               FancyBot.off break;
               }
         }         
   }
};
activatePackage(FancyBot);

//Greeting
package FancyBotGreet
{
   function newChatHud_addLine(%text)
   {
      
      Parent::newChatHud_addLine(%text);
      if(%text $="connected.")
      {
      FancyBot.Greet();
      }
   }
};
activatePackage(FancyBotGreet);

function FancyBotOn()
{
   new ScriptObject(FancyBot)
   {
   Greeting[1] = "I do fancy these players, dont you, Tee?.";
   Greeting[2] = "Good day to you, old chap.";
   Greeting[3] = "Indeed, a player it is, Tee.";
   Greeting[4] = "Hello, old chap.";
   Greeting[5] = "Good day, sir.";
   };
}

function FancyBot::Greet(%this)
{
      if(!isObject(%this)) return;
      %num = getRandom(1,5);
      commandtoserver('messagesent',"FancyBot: " @ %this.Greeting[%num]);
     
}

if (!$addedMarBotKeys)
{
   $remapDivision[$remapCount] = "Fancy Bot";
   $remapName[$remapCount] = "FancyBot On";
   $remapCmd[$remapCount] = "FancyBotOn";
   $remapCount++;
   $remapName[$remapCount] = "FancyBot Off";
   $remapCmd[$remapCount] = "FancyBot.Off";
   $remapCount++;
   $addedMarBotKeys = true;
}

function FancyBot::Off(%this)
{
if(!isObject(%this))return;
FancyBot.delete();
}

package FancyBotOn
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
      Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
          {
            switch$(%msg)
               {

            case "FancyBot On":
            FancyBotOn(); break;
               }
         }
   }
}'
activatePackage(FancyBotOn);      

So.. did you try saying "FancyBot On" or typing fancyBotOn(); in console?

You put in a ' instead of ; on the second last line.

So many things needlessly complicated
Why are you using scriptobjects?
Why are you deleting and remaking it?
I'm pretty sure $remapCmd[$remapCount] = "FancyBot.Off"; doesn't work

Honestly it looks like you're trying to learn way to many things all at once. Take it one at a time.

I suspect he modified the code from an add-on entitled "MarBot." I've never heard of this bot before, but...

if (!$addedMarBotKeys)
{

Code: [Select]
package FancyBotGreet
{
   function newChatHud_addLine(%text)
   {
      
      Parent::newChatHud_addLine(%text);
      if(%text $="connected.")
      {
      FancyBot.Greet();
      }
   }
};
activatePackage(FancyBotGreet);

no no no no NO!
whatever that doesn't work anyways