Author Topic: Chat Bot Not Working  (Read 1025 times)

Okay. Here's the deal. I seen a lot of people out there with those little chat bots where you say something and that chat bot replies under the owner's name. Well, I want one of those, y'know? So, I took a try and, well, the console says it has SYNTAX ERRORS! I know I have been more all-to with eventing more than scripting, but this really angers me. This is what the code looks like :


Quote
//Made by BLID 26544
package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
if (%msg %= "Activate BlueBot}
   if (%name $= "Azure")
      {
      commandToServer('messageSent',"BlueBot : 2 + 2 = 4! Yipee!");
      }
   }
}
};
activatePackage(chatbot);


It really sucks, because I got the chat bot straight from a tutorial. Shucks. Maybe I am just naturally the 'guy who can't script no matter what people tell him.'
But if you can manage to fix it, then please tell me how. Then you get this special chocolate chip cookie!

 :cookie:

Try reading your own code, it's literally a typo with the correct version right next to it.

Try reading your own code, it's literally a typo with the correct version right next to it.

What do you mean by that..?

What do you mean by that..?

Try reading your code.
if (%msg %= "Activate BlueBot} is invalid, but the correct form is on the line right below it.

Try reading your code.
if (%msg %= "Activate BlueBot} is invalid, but the correct form is on the line right below it.

Um, I don't know what you mean? Those 2 lines are supposed to function as, for if I have just said Activate BlueBot, it will make BlueBot say : '2 + 2 = 4! Yipee!'.
So, really, I don't get what you mean either. ._.

Try reading your code.
if (%msg %= "Activate BlueBot} is invalid, but the correct form is on the line right below it.
Oh, I see the typo... Darn cant believe i never noticed that was supposed to be parenthesis. Lol. Okay I will change it and test.

Oh, I see the typo... Darn cant believe i never noticed that was supposed to be parenthesis. Lol. Okay I will change it and test.

Crap, it's still not working. Still saying it has syntax errors.

if(%msg %= "Activate BlueBot}

Should be

if(%msg $= "Activate BlueBot")

If you properly indented your code the second error would be easy to identify as well

//Made by BLID 26544
package chatbot
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
      if (%msg %= "Activate BlueBot")
         if (%name $= "Azure")
         {
            commandToServer('messageSent',"BlueBot : 2 + 2 = 4! Yipee!");
         }
      }
   }
};
activatePackage(chatbot);
Hint: You're missing a bracket somewhere
Also on the Activate BlueBot line you had a closing bracket instead of a closing parenthesis.

Also if you look at the console it says where the error is.
Next, if you get a text editor that has syntax highlighting (I use Notepad++), it can help out on some things like this. If you place the insertion point next to a bracket, it will highlight that bracket, and the corresponding open/close bracket
Finally, don't use these for more then testing purposes. They annoy people.
« Last Edit: December 11, 2011, 09:41:12 AM by Headcrab Zombie »

You also need a semicolon at the end of parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

I thought it was clientCmdMessageSent ?

Nope.

clientCmdChatMessage - chat message received (chatMessageClient/chatMessageAll/commandToClient/commandToAll) from server
clientCmdServerMessage - general message received (messageClient/messageAll/etc) from server
serverCmdMessageSent - chat message received (commandToServer) from client
« Last Edit: December 11, 2011, 12:57:56 PM by Port »

I fixed it up for you, should work now
Code: [Select]
//Made by BLID 26544
package chatbot
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      switch$(%msg)
      {
            case "Activate BlueBot":
                    if (%name $= "Azure")
                    {
                        commandToServer('messageSent',"BlueBot : 2 + 2 = 4! Yipee!");
                    }
                    break;

             //case "Your Message Here":
                      //if (%name $= "Azure")
                      //{
                          //commandToServer('messageSent',"BlueBot: put message here!");
                          //break;
                      //}
      }
   }
};
activatePackage(chatbot);
« Last Edit: December 11, 2011, 01:34:03 PM by FFSO »