Author Topic: my chatbot problem  (Read 745 times)

Code: [Select]
package chatbot {
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg) {
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if (%msg $= "testing testing 123") {}
if (%name $= "tylerk196") {
commandToServer('messageSent',"Your testing is win!");
}

}
};
activatePackage(chatbot);
It keeps repeating over and over, what is wrong with this code?


P.S. how do you add a activate/deactivate? this is going to be a AFK chatbot

You closed the first if too early, so all it's doing is checking if you talked.

so i move the close to the end?

try formatting your code in a more consistent manner - it helps to see whats actually going on:

Code: [Select]
package chatbot
  {
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
     {
      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      if (%msg $= "testing testing 123")
        {
        }
      if (%name $= "tylerk196")
        {
         commandToServer('messageSent',"Your testing is win!");
        }

     }
  };
activatePackage(chatbot);

I made no changes to your script, I just reformatted

What you're going to want to do is delete the first if statement (hint: remove the {} too) and change the second one to
Code: [Select]
if(%name $= "tylerk196" && %msg $= "testing testing 123")

Otherwise, I see no issues.