Author Topic: Chatbot Error (I don't know where to put this)  (Read 2674 times)

//Crome, 29897
'package chatbot {',
'function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg) {'
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg);
if (%msg $= "Hello.") {
}
};
activatePackage(chatbot);
    if (%name $= "Crome") {
 commandToServer('messageSent',"Hey, smexy.");
     }
}

Did I do anything wrong? This is my first time trying, I've looked over and over but can't find the problem.

There's so much wrong with it that I'm not even going to start.

EDIT: HERE. Read this tutorial on TorqueScript.
« Last Edit: July 22, 2013, 09:51:41 PM by jes00 »

//Crome, 29897
'package chatbot {',
'function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg) {'
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%fmsg);
if (%msg $= "Hello.") {
}
};
activatePackage(chatbot);
    if (%name $= "Crome") {
 commandToServer('messageSent',"Hey, smexy.");
     }
}

Did I do anything wrong? This is my first time trying, I've looked over and over but can't find the problem.

I'm going to ask you honestly, did you just rip code and try to rearrange it?

Here's a working version with comments to show you what each part does


//Chrome 29897
package chatbot  //Start a package so we can activate and deactive the mod
{
  function clientcmdchatmessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)  //The function called when a player chats
  {
    parent::clientcmdchatmessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);  //Parent the function so it operates otherwise normally
    if(%name $= "Chrome")  //Check if your name is Chrome
    {
      if(%msg $= "Hello)  //Check if the message reads Hello
      {
        commandToServer('messageSent',"Heyo");  //This is what the bot will say
       }
     }
   }
};  //Close the package
ActivatePackage(Chatbot);  //Activate the package


You definitely need to read up on syntax, and I know people that there are more efficient and better ways to do it, let's not confuse the poor kid too much before he even knows proper syntax.

There is a much cleaner version.
Where there are strings, meaning multiple command-response thinggies.
(Show em yola)

Code: [Select]
      if(%msg $= "Hello")  //Check if the message reads Hello - You forgot a " at the end
Replace Yenola's if(%msg $= "Hello) to above.

There is a much cleaner version.
Where there are strings, meaning multiple command-response thinggies.
(Show em yola)
Read the end of my post, once he grasps syntax he can move on to learning other things

Code: [Select]
      if(%msg $= "Hello")  //Check if the message reads Hello - You forgot a " at the end
Replace Yenola's if(%msg $= "Hello) to above.
Thanks for catching that

There's so much wrong with it that I'm not even going to start.

EDIT: HERE. Read this tutorial on TorqueScript.
giving that to new coders is 100% useless, blockland has so many modifications of torque script that it's better to have a coder from blockland to teach you, or learn from other codes.

to new blockland coders: dont refer to those .pdfs until you know the basics.

-blah-
Don't do this. While you might think that comparing the name ensures that you sent the message, any host that knows what's going on can easily fake messages sent by you.

Don't do this. While you might think that comparing the name ensures that you sent the message, any host that knows what's going on can easily fake messages sent by you.

I know people that there are more efficient and better ways to do it, let's not confuse the poor kid too much before he even knows proper syntax.

I know, but that's what his original code was meant to do, therefore that's what he wants it to do.  Throwing in a thousand 'better' way to do things that are more advanced is just going to confuse him especially if he barely understand syntax.

Throwing in a thousand 'better' way to do things that are more advanced
Using NHM_Type::Send isn't advanced at all; IMO it's simpler, because you can remove the if statement checking the name, and the function has a lot less arguments. Other than that it's all the same: a package declaration, a function declaration, a comparison, a commandtoserver call, and a parent call.
« Last Edit: July 23, 2013, 02:23:51 PM by Headcrab Zombie »

Using NHM_Type::Send isn't advanced at all; IMO it's simpler, because you can remove the if statement checking the name, and the function has a lot less arguments.
It's also required for security reasons.

-snip-
That code can be done better. You will not confuse people by providing them a simpler and neater way to do this :

Code: [Select]
package chatbot  //package it so we don't mess things up and override the function
{
function NMH_Type::Send(%this) //a function called when you chat something
{
%messageSent = %this.getValue(); //get the text I chatted
if(%messageSent $= "Hello" || %messageSent $= "hello" || %messageSent $= "hi" || %messageSent $= "Hi" || %messageSent $= "Hey" || %messageSent $= "hey") //if I chatted any one of these options such as Hi, hi, hello, Hello, hey, or Hey then
{
commandToServer('messageSent', "CromeBot : Hey, smexy."); //make the chatbot say this
}
Parent::Send(%this); //parent it so we don't mess it up and override this function
}
};  //close the package
activatePackage(chatbot);

See how much simpler it can become?

Without the comments :
Code: [Select]
package chatbot 
{
function NMH_Type::Send(%this)
{
%messageSent = %this.getValue();
if(%messageSent $= "Hello" || %messageSent $= "hello" || %messageSent $= "hi" || %messageSent $= "Hi" || %messageSent $= "Hey" || %messageSent $= "hey")
{
commandToServer('messageSent', "CromeBot : Hey, smexy.");
}
Parent::Send(%this);
}
};
activatePackage(chatbot);
« Last Edit: July 23, 2013, 03:41:15 PM by Pacnet2012³ »

holy loving stuff
is op high?

holy loving stuff
is op high?
no he just has absolutely no idea what he is doing

Original post had so much wrong with it i almost cried take a  :cookie: for trying(: