Author Topic: Toggling client chatbot on/off?  (Read 3530 times)

I have a client-sided chatbot that I've made but I would like to be able to tell him a command and then he would de-activate until I say another command, which would turn him back on. The only problem is, I'm not quite sure how to do this.

Make it so, when you say "CHATTBOT off" it sets $CHATBOToff to 1. Then, put an if check around all the bot's code to make sure that is "!$CHATBOToff"

Or if it's in a package you could do deactivatepackage(chatbot);

Just an example.
Code: [Select]
function chatbot_Toggle(%x) {
     if(%x)
          $chatbot = 0;
     else
          $chatbot = 1;
}

package chatbot {
     function whateverYouUseForTheChatbot(%args, %str, %theclient) {
          parent::whateverYouUseForTheChatbot(%args, %str, %theclient);
          if($chatbot && %theclient $= "yourname" && %str $= "Turn off.")
               chatbot_toggle(1);
          else if(%theclient $= "yourname" && %str $= "Turn on.")
               chatbot_toggle();
          if($chatbot && %str $= "Hello chatbot!")
               commandToServer('messageSent', "CHATBOT| Hi.");
          else
               echo("Disabled! c:");
     }
};
activatePackage(chatbot);

Honestly, that's coded a bit worse than people say I code. I'd provide my own example, but I'd rather repair his code than try an example which might not fit into his variation.

So if I had:

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")
commandToServer('messageSent',"<color:e5e500>Mimic<color:ffffff>: This was a triumph!");
else if(%msg $= "Hi Mimic")
commandToServer('messageSent',"<color:e5e500>Mimic<color:ffffff>: Hello how are you?");

}

};
activatePackage(chatbot);

I would change it to:
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")
commandToServer('messageSent',"<color:e5e500>Mimic<color:ffffff>: This was a triumph!");
else if(%msg $= "Hi Mimic")
commandToServer('messageSent',"<color:e5e500>Mimic<color:ffffff>: Hello how are you?");
else if(%msg $= "Go to sleep mimic")
deactivatepackage(chatbot);
else if(%msg $= "Wake up Mimic")
activatepackage(chatbot);

}

};
activatePackage(chatbot);
if I was doing it Bloxxed's way?

Code: [Select]
That way would break it, since the package is no longer on to work and turn itself on.

[codepackage MimicBot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(firstWord(%msg) $= "Mimic," && (!$MimicBotOff || %msg $= "Mimic, Wake up"))
{
switch$(restWords(%msg))
{
case "Testing":
commandToServer('messageSent', "Mimic: This was a triumph!");
case "Hi":
commandToServer('messageSent', "Mimic: Hello how are you?");
case "Go to sleep":
$MimicBotOff = 1;
case "Wake up":
$MimicBotOff = 0;
}
}
}
};
activatePackage(MimicBot);

1: You can't put color code in regular chat, unless the host has some stupid chat mod.
2: It's better to only activate if you start by saying "Mimic, " so no one accidentally sets it off.
3: I turned it into a switch check for now, since you only have specific statements to check.
4: Using variables means that it can always check.
5: Wait for even more responses, as they will probably be much better...

1: You can't put color code in regular chat, unless the host has some stupid chat mod.
2: It's better to only activate if you start by saying "Mimic, " so no one accidentally sets it off.
3: I turned it into a switch check for now, since you only have specific statements to check.
4: Using variables means that it can always check.
5: Wait for even more responses, as they will probably be much better...

1: Huh, its always worked perfectly fine with colorcodes on every server I've used him on.
2: I'm not really sure how to do that :I I'm not very good with toruquescript yet. (I noticed you did that though in your version, I'll have to mess around with that so I can understand it better.)
3: Alright, I'll use that for now.
4: Okay, I'll be sure to remember that.
5: Actually, yours was pretty useful, thanks. I'm open to any other help though.
« Last Edit: August 20, 2011, 07:34:17 PM by slimabob »

YES! I got him to work! On the way, I discovered he had about 15 other syntax errors but I fixed them all! I'm so happy :D
« Last Edit: August 20, 2011, 08:00:56 PM by slimabob »

I'm so confused... It executes properly but doesn't respond to anything I say to him. Ive tried telling him to wake up but that has no effect.

Code: [Select]
package MimicBot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(firstWord(%msg) $= "Mimic" && (!$MimicBotOff || %msg $= "Mimic Wake up"))
{
switch$(restWords(%msg))
{
case "Testing":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: This was a triumph!");
case "Hi":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Hello how are you?");
case "Good":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: That's not good, that's Great!");
case "lol":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: HAHAHAHAHAHAAA I don't get it..");
case "derp":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Herp-a-Derp.");
case "wtf":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: What the fail?!? I don't understand your human language at all..");
case "Mimic":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: What do you want?");
case "Hi":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Hello.");
case "Cool":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: What are you talking about?! I'm not cold!");
case "I don't know":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Wait, you DON'T know?! Everyone knows!!");
case "What?":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: You heard him!");
case "NO U":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: No, i do believe he WAS talking to you.");
case "slimabob":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Hey, I know that guy!");
case "No wait":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: No you wait. This is MY game MY rules.");
case "Hi everyone.":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: I don't see anyone here i like..");
case "Shut up":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: No you shut the up.");
case "No YOU shut up":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: No you do this shutting up thing!");
case "afk":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Quick, he's going afk! Do all sorts of annoying stuff to him before he comes back!");
case "This sentence is false.":
commandToServer('messageSent',"<color:e5e500>Mimic<color:ffffff>: FFFFFFFUUUUUUUUUUU- PARADOOX!!!!!!!!");
case "Cake":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: LIES! THERE IS NO CAKE!");
case "That makes mimic sad.":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: WAAAAAAA I'M FEELING SIMULATED SADNESS!!!!");
case "who are you?":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: To tell you the truth, I have no idea.");
case "Youre stupid!":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: Technicaly, since I'm a computer program, I'm smarter than you..");
case "your mom":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: I don't have a mom, I'm an orphan.");
case "bye":
commandToServer('messageSent', "<color:e5e500>Mimic<color:ffffff>: BYE! DON'T COME BACK!");
case "Go to sleep":
$MimicBotOff = 1;
case "Wake up":
$MimicBotOff = 0;
}
}
}
};
activatePackage(MimicBot);

Crap triple post....

Add:
-a Default in the switch to see if it's not registering chat right
-Several echos saying "phase _ OK" in different areas of the script

You can't use loving colors.

Try it now:
Code: [Select]
package MimicBot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(firstWord(%msg) $= "Mimic" && (!$MimicBotOff || %msg $= "Mimic Wake up"))
{
switch$(restWords(%msg))
{
case "Testing":
commandToServer('messageSent', "Mimic: This was a triumph!");
case "Hi":
commandToServer('messageSent', "Mimic: Hello how are you?");
case "Good":
commandToServer('messageSent', "Mimic: That's not good, that's Great!");
case "lol":
commandToServer('messageSent', "Mimic: HAHAHAHAHAHAAA I don't get it..");
case "derp":
commandToServer('messageSent', "Mimic: Herp-a-Derp.");
case "wtf":
commandToServer('messageSent', "Mimic: What the fail?!? I don't understand your human language at all..");
case "Mimic":
commandToServer('messageSent', "Mimic: What do you want?");
case "Cool":
commandToServer('messageSent', "Mimic: What are you talking about?! I'm not cold!");
case "I don't know":
commandToServer('messageSent', "Mimic: Wait, you DON'T know?! Everyone knows!!");
case "What?":
commandToServer('messageSent', "Mimic: You heard him!");
case "NO U":
commandToServer('messageSent', "Mimic: No, i do believe he WAS talking to you.");
case "slimabob":
commandToServer('messageSent', "Mimic: Hey, I know that guy!");
case "No wait":
commandToServer('messageSent', "Mimic: No you wait. This is MY game MY rules.");
case "Hi everyone.":
commandToServer('messageSent', "Mimic: I don't see anyone here i like..");
case "Shut up":
commandToServer('messageSent', "Mimic: No you shut the up.");
case "No YOU shut up":
commandToServer('messageSent', "Mimic: No you do this shutting up thing!");
case "afk":
commandToServer('messageSent', "Mimic: Quick, he's going afk! Do all sorts of annoying stuff to him before he comes back!");
case "This sentence is false.":
commandToServer('messageSent',"Mimic: FFFFFFFUUUUUUUUUUU- PARADOOX!!!!!!!!");
case "Cake":
commandToServer('messageSent', "Mimic: LIES! THERE IS NO CAKE!");
case "That makes mimic sad.":
commandToServer('messageSent', "Mimic: WAAAAAAA I'M FEELING SIMULATED SADNESS!!!!");
case "who are you?":
commandToServer('messageSent', "Mimic: To tell you the truth, I have no idea.");
case "Youre stupid!":
commandToServer('messageSent', "Mimic: Technicaly, since I'm a computer program, I'm smarter than you..");
case "your mom":
commandToServer('messageSent', "Mimic: I don't have a mom, I'm an orphan.");
case "bye":
commandToServer('messageSent', "Mimic: BYE! DON'T COME BACK!");
case "Go to sleep":
$MimicBotOff = 1;
case "Wake up":
$MimicBotOff = 0;
}
}
}
};
activatePackage(MimicBot);
Oh and if this is supposed to be a server mod use messageAll instead of messageSent.

Code: [Select]
package MimicBot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
Parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(firstWord(%msg) $= "Mimic,")
{
%restW = restWords(%msg);
if(%restW $= "Go to sleep")
{
$MimicBotOff = 1;
%mimic = "But I haven't had supper yet! D:";
}
else if(%restW $= "Wake up")
{
$MimicBotOff = 0;
%mimic = "I'm up! What?";
}
else if(!$MimicBotOff)
{
switch$(restWords(%msg))
{
case "Testing":
%mimic = "This was a triumph!";
case "Hi":
%mimic = "Hello how are you?";
case "Good":
%mimic = "That's not good, that's Great!";
case "lol":
%mimic = "HAHAHAHAHAHAAA I don't get it..";
case "derp":
%mimic = "Herp-a-Derp.";
case "wtf":
%mimic = "What the fail?!? I don't understand your human language at all..";
case "Mimic":
%mimic = "What do you want?";
case "Hi":
%mimic = "Hello.";
case "Cool":
%mimic = "What are you talking about?! I'm not cold!";
case "I don't know":
%mimic = "Wait, you DON'T know?! Everyone knows!!";
case "What?":
%mimic = "You heard him!";
case "NO U":
%mimic = "No, i do believe he WAS talking to you.";
case "slimabob":
%mimic = "Hey, I know that guy!";
case "No wait":
%mimic = "No you wait. This is MY game MY rules.";
case "Hi everyone.":
%mimic = "I don't see anyone here i like..";
case "Shut up":
%mimic = "No you shut the up.";
case "No YOU shut up":
%mimic = "No you do this shutting up thing!";
case "afk":
%mimic = "Quick, he's going afk! Do all sorts of annoying stuff to him before he comes back!";
case "This sentence is false.":
%mimic = "FFFFFFFUUUUUUUUUUU- PARADOOX!!!!!!!!";
case "Cake":
%mimic = "LIES! THERE IS NO CAKE!";
case "That makes mimic sad.":
%mimic = "WAAAAAAA I'M FEELING SIMULATED SADNESS!!!!";
case "who are you?":
%mimic = "To tell you the truth, I have no idea.";
case "Youre stupid!":
%mimic = "Technicaly, since I'm a computer program, I'm smarter than you..";
case "your mom":
%mimic = "I don't have a mom, I'm an orphan.";
case "bye":
%mimic = "BYE! DON'T COME BACK!";
}
}
if(strLen(%mimic))
commandToServer('messageSent', "Mimic: " @ %mimic);
}
}
};
activatePackage(MimicBot);

You didn't have the comma in the first word check. Say "Mimic, " and one of those cases to get a response. And you do realize that the color doesn't show in those servers, right? the tags are useless if they are automatically removed before anyone can see them, waste of bytes, so don't use them.
« Last Edit: August 22, 2011, 04:22:16 AM by MegaScientifical »

Protip: You can use more than one line in a switch check.