Author Topic: What's wrong with this script?  (Read 964 times)

I got a script off of JJStorms forums, it's a ChatBot.  I edited it and now I'm not sure what's wrong with it, it's not working, I cannot turn it on.

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

            case "Testing":
            if(%name $= "Boshy Pie")
               {
               commandToServer('messageSent', "BamBot: This was a triumph!"); break;
               }

            case "Good":
            commandToServer('messageSent', "BoshBot: Thats not good, thats great!"); break;

            case "lol":
               commandToServer('messageSent', "Boshbot: I didn't get it.."); break;
            case "derp":
               commandToServer('messageSent', "Boshbot: Herp-a-Derp"); break;

            case "wtf":
               commandToServer('messageSent', "Boshbot: What the what!?  Whatch your mouth, forgettard!"); break:
            case "RobBot":
               commandToServer('messageSent', "Boshbot: brother whaat?  brother whooo?"); break;
            case "Cool":
               commandToServer('messageSent', "Boshbot: I'm actually somewhat hot"); break;

            case "idk":
               commandToServer('messageSent', "Boshbot: You don't know!? Everyone knows the bird is the word!"); break;

            case "What?":
               commandToServer('messageSent', "Boshbot: You heard him!"); break;

            case "Wait":
               commandToServer('messageSent', "Boshbot: No YOU wait!"); break;
            case "shut up":
               commandToServer('messageSent', "Boshbot: brother what you just say to me?  I'll pop a cap in yo' ass!"); break;

            case "no you shut up":
               commandToServer('messageSent', "Boshbot: How about you piss off, cracker?"); break;

            case "afk":
               commandToServer('messageSent', "Boshbot: do it now!"); break;

            case "cake":
               commandToServer('messageSent', "Boshbot: What's that slang for?"); break;

            case "That makes boshBot sad":
            commandToServer('messageSent', "Boshbot: WAAAAAA I'M FEELING SIMULATED SADNESS!!"); break;

            case "who are you?":
               commandToServer('messageSent', "Boshbot: why the forget are you asking me, brother?"); break;

            case "youre stupid":
            commandToServer('messageSent', "Boshbot: brother, you don't know me!"); break;
            case "I'm Love you, BoshBot":
            commandToServer('messageSent', "Boshbot: I love big Booty Hoes"); break;

            case "your mom":
               commandToServer('messageSent', "Boshbot: You mean Bosh?"); break;

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

            case "Fart":
               commandToServer('messageSent', "Boshbot: SAFETY!!!"); break;

            case "gtg":
               commandToServer('messageSent', "Boshbot: Get The Girl? brother, my hoes are unlimited."); break;

            case "Boshbot, Off":
               BamBot.delete(); break;
             
            case "Boshbot, Clear Spam":
               CommandToServer('ClearSpamBricks'); break;

            case "Boshbot, Clear My Bricks.":
               CommandToServer('ClearBricks'); break;
            
            case "Boshbot, Clear Floating Bricks! ":
               CommandToServer('ClearFloatingBricks'); break;
               }
         }         
   }
};
activatePackage(boshBot);

//Greeting
package BoshBotGreet
{
   function newChatHud_addLine(%text)
   {
      Parent::newChatHud_addLine(%text);
      %UnusedVar = strReplace(%text," connected.","");

      if(%UnusedVar !$= %text)
      {
         boshBot.Greet();
      }
   }
};
activatePackage(BoshBotGreet);

function BoshBotOn()
{
   new ScriptObject(BoshBot)
   {
   Greeting[1] = "Wazzuuuuup?.";
   Greeting[2] = "Hey.";
   Greeting[3] = "Yo.";
   Greeting[4] = "Hi.";
   Greeting[5] = "What up, mah brother?";
   Greeting[6] = "Wazzup?.";
   };
}

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

if (!$addedBamBotKeys)
{
   $remapDivision[$remapCount] = "Rob Bot";
   $remapName[$remapCount] = "BoshBot On";
   $remapCmd[$remapCount] = "BoshBotOn";
   $remapCount++;
   $remapName[$remapCount] = "BoshBot Off";
   $remapCmd[$remapCount] = "BoshBot.Off";
   $remapCount++;
   $addedAdamBotKeys = true;
}

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

Code: [Select]
if(isObject(RobBot))
Code: [Select]
new ScriptObject(BoshBot)
Also, that greet is a VERY bad idea.
For example, I say "connected." your bot will spam "Hey."

Quote
For example, I say "connected." your bot will spam "Hey."
Can I change it to when the console says someone has connected?  Or is that possible?

Can I change it to when the console says someone has connected?  Or is that possible?
Code: [Select]
package autogreet
{
    function secureClientCmd_ClientJoin(%name, %objid, %blid, %score, %isbot, %admin, %sa)
    {
        parent::secureClientCmd_ClientJoin(%name, %objid, %blid, %score, %isbot, %admin, %sa);
        doGreet(%name);
    }
};
activatePackage(autogreet);
Then just make a doGreet(%name) function that greets the person with the specified name.

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

            case "Testing":
            if(%name $= "Boshy Pie")
               {
               commandToServer('messageSent', "BamBot: This was a triumph!"); break;
               }

            case "Good":
            commandToServer('messageSent', "BoshBot: Thats not good, thats great!"); break;

            case "lol":
               commandToServer('messageSent', "Boshbot: I didn't get it.."); break;
            case "derp":
               commandToServer('messageSent', "Boshbot: Herp-a-Derp"); break;

            case "wtf":
               commandToServer('messageSent', "Boshbot: What the what!?  Whatch your mouth, forgettard!"); break:
            case "RobBot":
               commandToServer('messageSent', "Boshbot: brother whaat?  brother whooo?"); break;
            case "Cool":
               commandToServer('messageSent', "Boshbot: I'm actually somewhat hot"); break;

            case "idk":
               commandToServer('messageSent', "Boshbot: You don't know!? Everyone knows the bird is the word!"); break;

            case "What?":
               commandToServer('messageSent', "Boshbot: You heard him!"); break;

            case "Wait":
               commandToServer('messageSent', "Boshbot: No YOU wait!"); break;
            case "shut up":
               commandToServer('messageSent', "Boshbot: brother what you just say to me?  I'll pop a cap in yo' ass!"); break;

            case "no you shut up":
               commandToServer('messageSent', "Boshbot: How about you piss off, cracker?"); break;

            case "afk":
               commandToServer('messageSent', "Boshbot: do it now!"); break;

            case "cake":
               commandToServer('messageSent', "Boshbot: What's that slang for?"); break;

            case "That makes boshBot sad":
            commandToServer('messageSent', "Boshbot: WAAAAAA I'M FEELING SIMULATED SADNESS!!"); break;

            case "who are you?":
               commandToServer('messageSent', "Boshbot: why the forget are you asking me, brother?"); break;

            case "youre stupid":
            commandToServer('messageSent', "Boshbot: brother, you don't know me!"); break;
            case "I'm Love you, BoshBot":
            commandToServer('messageSent', "Boshbot: I love big Booty Hoes"); break;

            case "your mom":
               commandToServer('messageSent', "Boshbot: You mean Bosh?"); break;

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

            case "Fart":
               commandToServer('messageSent', "Boshbot: SAFETY!!!"); break;

            case "gtg":
               commandToServer('messageSent', "Boshbot: Get The Girl? brother, my hoes are unlimited."); break;

            case "Boshbot, Off":
               BamBot.delete(); break;
             
            case "Boshbot, Clear Spam":
               CommandToServer('ClearSpamBricks'); break;

            case "Boshbot, Clear My Bricks.":
               CommandToServer('ClearBricks'); break;
            
            case "Boshbot, Clear Floating Bricks! ":
               CommandToServer('ClearFloatingBricks'); break;
               }
         }         
   }
};
activatePackage(boshBot);

//Greeting
package BoshBotGreet
{
   function newChatHud_addLine(%text)
   {
      Parent::newChatHud_addLine(%text);
      %UnusedVar = strReplace(%text," connected.","");

      if(%UnusedVar !$= %text)
      {
         boshBot.Greet();
      }
   }
};
activatePackage(BoshBotGreet);

function BoshBotOn()
{
   new ScriptObject(BoshBot)
   {
   Greeting[1] = "Wazzuuuuup?.";
   Greeting[2] = "Hey.";
   Greeting[3] = "Yo.";
   Greeting[4] = "Hi.";
   Greeting[5] = "What up, mah brother?";
   Greeting[6] = "Wazzup?.";
   };
}

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

if (!$addedBamBotKeys)
{
   $remapDivision[$remapCount] = "Rob Bot";
   $remapName[$remapCount] = "BoshBot On";
   $remapCmd[$remapCount] = "BoshBotOn";
   $remapCount++;
   $remapName[$remapCount] = "BoshBot Off";
   $remapCmd[$remapCount] = "BoshBot.Off";
   $remapCount++;
   $addedAdamBotKeys = true;
}

function BamBot::Off(%this)
{
if(!isObject(%this))return;
BoshBot.delete();
}
I believe I've done everything asked, still isn't working.

I believe I've done everything asked, still isn't working.
"Doesn't work" is not really a description of what goes wrong.

Goign into the console, I type deactivatepackage(BoshBot); then activatepackage(BoshBot); and it says that BoshBot isn't a package.

Wow, you have too many different names for the bot so that its hard to follow the workflow, but from what I've come up with:

Change
Code: [Select]
case "Boshbot, Off":
  BamBot.Delete(); break;
Code: [Select]
  $remapCmd[$remapCount] = "BoshBot.Off";
To:
Code: [Select]
case "Boshbot, Off":
  BamBot.Off(); break;
Code: [Select]
  $remapCmd[$remapCount] = "BamBot.Off";
Or
Code: [Select]
case "Boshbot, Off":
  BoshBot.Delete(); break;
Code: [Select]
  $remapCmd[$remapCount] = "BoshBot.Delete";
« Last Edit: May 30, 2013, 11:21:33 AM by Vaux »