Author Topic: Script not detecting chat {resolved}  (Read 3732 times)

Script not working
wtf yelona :P

Code: [Select]
package Grammarnational socialist
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {

      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      if (name $= "Johnny Blockhead")
      {
         switch$(%msg) //let's add the switch now
         {
            case "lel":
            commandToServer('messagesent',"JSys²: Don't ya mean lol?");

            case "jsut":
            commandToServer('messagesent',"JSys²: Don't ya mean just?");

case "alot":
            commandToServer('messagesent',"JSys²: I really hope you mean't to say a lot.");
           

         }
      }
   }

};
What's ironic is that you misspelled "meant."

Here is how my bot works.

Code: [Select]
$MessagePrefix = "#"; //Say # in chat like a command
$FunctionPrefix = "ChatBot_"; //Function names (Shown below)
$ChatBot::Name = "ChatBot"; //Chatbot's name

package ChatBot
{
function NMH_Type::send( %this )
{
%value = %this.getValue();
%length = strLen($MessagePrefix);
if(getSubStr(%value,0,%length) $= $MessagePrefix)
{
%this.setValue("");
%value = getSubStr(%value, %length, strLen(%value));
if(isFunction(%func = $FunctionPrefix @ firstWord(%value)))
{
call(%func,restWords(%value));
}
}
else
{
%this.setValue(%value);
}
parent::send( %this );
}
};
activatePackage(ChatBot);

Put down a function as like

Code: [Select]
function ChatBot_Hi()
{
commandToServer('messagesent',$ChatBot::Name @ ": Hi!");
}
Say #hi in the chat and the bot will say Hi

Creating a command:
Code: [Select]
function ChatBot_CommandName(%string)
{
//stuff here
}
« Last Edit: August 11, 2013, 02:44:51 AM by Advanced Bot »

The variable "name" in the if statement needs to be prefixed by a %.

Script not working
wtf yelona :P

Code: [Select]
Grammarnational socialist

You also have to activate the package after the }; as well as change

name to %name because %name is a local string variable and not an object
« Last Edit: August 11, 2013, 09:35:02 AM by {Pacnet2013} »

Script not working
wtf yelona :P
Checking %name to see if it's sent by you completely breaks the purpose of you switching from NMH_Type::send to clientCmdChatMessage
Also you're checking if the msg is equal to the word, not if it contains the word.
So it'll only detect it if someone says exactly "jsut" and not any other words with the message.
« Last Edit: August 11, 2013, 11:57:30 AM by Headcrab Zombie »

Script not working
wtf yelona :P

Code: [Select]
package Grammarnational socialist
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {

      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      if (name $= "Johnny Blockhead")
      {
         switch$(%msg) //let's add the switch now
         {
            case "lel":
            commandToServer('messagesent',"JSys²: Don't ya mean lol?");

            case "jsut":
            commandToServer('messagesent',"JSys²: Don't ya mean just?");

case "alot":
            commandToServer('messagesent',"JSys²: I really hope you mean't to say a lot.");
           

         }
      }
   }

};

Your script is only checking if somebody's entire message body is "jsut" or "lel".
I would use striPos to determine if the word is inside the message body.
For example
%msg is "Cancerous tumors"
striPos("tumors",%msg) == 9
striPos("9/11",%msg) == -1
So if you do striPos("jsut",%msg) and get -1, then you know that they didn't say it. If it's not -1, they did say it, and you can correct them.

You need a ; after the package closing bracket
Or am I just very
very
late?