Author Topic: How would I add more commands/responses to my chatbot?  (Read 3165 times)

Hey, I made a chatbot.

Code: [Select]
//This is made by the glorious elephant hugger, Johnny Blockhead 26
package chatbot {
function
clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if (%msg $= "I have a chatbot. Her name is Carl.")
if (%name $= "Johnny Blockhead 26") {
commandToServer('messagesent',"CarlBot: My name is Carl!");
}
}

};
activatepackage(chatbot);

How would I make it so she would respond to more then just one command?
I tried various ways, loaded em, and got errors.
I am not really shure what to do...
Do I have to make a whole entire new addon?
Please help

It would be the most appreciated if you just added it in using correct formatting
Code: [Select]
if (%msg $= "Carl, how are you doing?.")
if (%name $= "Johnny Blockhead 26") {
commandToServer('messagesent',Well, today some gangstas beat me up.");

Edit: Most of the first page is from a different subject matter
« Last Edit: June 21, 2013, 08:10:10 PM by Johnny Blockhead »

//This is made by the glorious elephant hugger, Johnny Blockhead 26
package chatbot {
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg)
{

if (%msg $= "testing testing 123")
if (%name $= "Cabinet") {
      commandToServer('messagesent',"Your testing is win!");
   }
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg);
}
};
activatepackage(chatbot)


Not sure what those random apostrophes were, and the ending {} made no sense, I dislike the formatting you're choosing but a good amount of people do it your way so I'm not going to 'correct' that.  This should (in theory) run perfectly fine

Hey, I tried to make a chatbot from this tutorial:
http://forum.blockland.us/index.php?topic=143501.0
and it is not working....
Here is my code

Code: [Select]
//This is made by the glorious elephant hugger, Johnny Blockhead 26
'package chatbot {'
'function
clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg)
{'
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg);
if (%msg $= "testing testing 123")
if (%name $= "Cabinet") {
commandToServer('messagesent',"Your testing is win!");
}
}
{}
};
activatepackage(chatbot);

My singleplayer name is Cabinet, yeah.
(Deep breath) Ok. Let's begin.

Code: [Select]
'package chatbot {'
'function
clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg)
{'
Remove the useless 's, their causing syntax errors.

Code: [Select]
if (%name $= "Cabinet") {
Replace this with if (%name $= $Pref::Player::NetName) { because that way it will detect if it's you, even if you change your name.

What is the useless {} at the bottom for? Remove it.

Your organization is also horrible. I suggest that you improve it so that you can look through your code more easily.

Warning - while you were typing a new reply has been posted. You may wish to review your post.
-_- Yenola, you spoon feeder, you.

I listed the reasons below the code, I'm not going to treat him like a baby though, if a person doesn't have common sense then coding isn't something they should be learning.

Not sure what those random apostrophes were, and the ending {} made no sense, I dislike the formatting you're choosing but a good amount of people do it your way so I'm not going to 'correct' that.  This should (in theory) run perfectly fine

Sorry guys, as I said. I was using the guide in this topic: http://forum.blockland.us/index.php?topic=143501.0

Thanks though!

Improved code (I didn't want to do the if (%name $= $Pref::Player::NetName) { for personal reasons)

Code: [Select]
//This is made by the glorious elephant hugger, Johnny Blockhead 26
package chatbot {
function
clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg);
if (%msg $= "testing testing 123")
if (%name $= "Cabinet") {
commandToServer('messagesent',"Your testing is win!");
}
}

};
activatepackage(chatbot);

« Last Edit: June 21, 2013, 06:27:30 PM by Johnny Blockhead »

Sorry guys, as I said. I was using the guide in this topic: http://forum.blockland.us/index.php?topic=143501.0
There's no need to apologize, everyone has to learn from the beginning, there's a reason the coding help section exists.

If you need any more help, feel free to post here, and one of the acceptable things is to not lock topics in coding help, so try not to lock this one or any future topics

I also sugget to use the NMH_type::send(%this) function instead, and delaying the commandToServer. If you that then do %msg = %this.getValue(); too. If you use the clientCmdChatMessage function, you can be trolled by the server. You also don't need to check if it's you saying it, if you use the function above.

I just tested it, and it broke the chatsystem with Blockland!

Names aren't displayed and the chat is all red.
No matter what server!
(chatbotscript is clientsided)
Please Help!!!

EDIT: Can someone just take my original and modify it? I am not shure if it is something I did.....

2nd Edit: Someone, please help me. I uninstalled the addon but can someone tell me how to fix it...
« Last Edit: June 21, 2013, 06:59:11 PM by Johnny Blockhead »

Uh, it can't break chat if it's client sided.

Are you doing it jes's way or the original?

Are you sure it is packaged right?

- two of your arguments are named %fmsg in clientCmdChatMessage. (the second should be %msg)
- you're testing for if(%msg) so it won't work regardless of whether your chat works. (until you fix this ^)
« Last Edit: June 21, 2013, 07:06:54 PM by Placid »

Uh, it can't break chat if it's client sided.

Are you doing it jes's way or the original?

Are you sure it is packaged right?

I made a file named Client_ChatBot
Inside is the client.cs that the code is in
Then a description file

I am doing it Jes's Way.

Pic:
I type the chat is so quiet (with it installed)
and then this happens


Edit:
- two of your arguments are named %fmsg in clientCmdChatMessage.
- you're testing for if(%msg so it won't work regardless of whether your chat works.

So, I would delete the extra %fmsg
But how would I fix the 
if(%msg
« Last Edit: June 21, 2013, 07:07:05 PM by Johnny Blockhead »

Post your code if you're doing it Jes's way

Edit:
So, I would delete the extra %fmsg
But how would I fix the 
no, you would change the second one to %msg and that would fix the second problem too.

Post your code if you're doing it Jes's way
I already posted it.
no, you would change the second one to %msg and that would fix the second problem too.
Let me try that

Nothing changed.
Current Code:

Code: [Select]
//This is made by the glorious elephant hugger, Johnny Blockhead 26
package chatbot {
function
clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if (%msg $= "testing testing 123")
if (%name $= "Cabinet") {
commandToServer('messagesent',"Your testing is win!");
}
}

};
activatepackage(chatbot);

WAIT found a slight problem
« Last Edit: June 21, 2013, 07:16:45 PM by Johnny Blockhead »

Fixed! I <3 You all!


For The Wondering Forumer: I didn't replace all the fmsg s with msg s.

Thanks!

EDIT: How would I add more responses
plz help
« Last Edit: June 21, 2013, 09:14:47 PM by Johnny Blockhead »