Author Topic: My first chat bot (NEED HELP AGAIN)  (Read 2369 times)

went wrong? I made this first chat bot from a tutorial on how to make chat bots. I followed it and named my chat bot the Secbot. After my in-game name. Well at least half of it.
Anyway heres the main client.cs code for it:
Code: [Select]
//Secton
//8448
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 $= "Secton") {
commandToServer('messageSent',"Your testing is win, Secton!");
}
};
After starting the game I looked up in the console to see if it had any errors and yet it did. All it said was there are Syntax errors in my code and the error report was complete. Can somebody fix this?
« Last Edit: August 18, 2011, 10:59:28 AM by PurpleMetro »

You're missing a ton of closing brackets. (}) Add 3 before the };.

Well you nee--

Warning - while you were reading a new reply has been posted. You may wish to review your post. forget.

Here is what i have:

Code: [Select]
//Global Dbot Brain Variables
$Dbot::killstreaks = 1;
$Dbot::Chat = 1;
$Dbot::revenge = 1;
$Dbot::multikill = 1;
//Global Dbot Brain Variables

package Dbot
{
function servercmdMessageSent(%client, %message) {
parent::servercmdMessageSent(%client, %message);
%player = %client.getPlayerName();
if($Dbot::Chat == 1) {
if(strLwr(getSubStr(%message, 0, 12)) $= "Dbot say") {
messageAll("", "\c3Dbot" @ "\c6:" SPC getSubStr(%message, 12, strLen(%message)-12));
} else if(strLwr(getSubStr(%message, 0, 2)) $= "hi")
{
messageAll("", "\c3Dbot" @ "\c6:" SPC "Hi," SPC %player @ "!");

You should try writing code with the brackets on a seperate line, you can see them better and see if your missing something.
The parent::clientCmdChatMessage line is just a function call, it ends in a semicolon and doesn't have brackets.
And lastly, %msg is undefined
Code: [Select]
//Secton
//8448
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 $= "Secton")
                        {
commandToServer('messageSent',"Your testing is win, Secton!");
                        }
                 }
        }
};
ActivatePackage(chatbot);


-snip-
That's a server-side chat bot, OP wants a client-side bot.

(Every time someone makes a chat-bot related topic it reminds me that I still need to figure out a way to make mine answer questions)
« Last Edit: August 16, 2011, 07:33:02 PM by Headcrab Zombie »

You should try writing code with the brackets on a seperate line, you can see them better and see if your missing something.
The parent::clientCmdChatMessage line is just a function call, it ends in a semicolon and doesn't have brackets.
And lastly, %msg is undefined
Code: [Select]
//Secton
//8448
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 $= "Secton")
                        {
commandToServer('messageSent',"Your testing is win, Secton!");
                        }
                 }
        }
};
ActivatePackage(chatbot)

That's a server-side chat bot, OP wants a client-side bot.

(Every time someone makes a chat-bot related topic it reminds me that I still need to figure out a way to make mine answer questions)

Dosen't work... :(

Did you fix %msg being undefined?
I'm not entirely certain but try changing it to %fmsg
I also left out a semicolon, so fix that too.

Additionally, whenever you post in coding help, make sure you look in the console for any errors, because it would have picked that up

Did you fix %msg being undefined?
I'm not entirely certain but try changing it to %fmsg
I also left out a semicolon, so fix that too.

Additionally, whenever you post in coding help, make sure you look in the console for any errors, because it would have picked that up
Uhh.. Sorry but I dont get %msg being undefined really...

um, is there a reason he has two %fmsg args? i'm fairly certain that he needs to have it as %a, %b, %c, %fmsg, %cp, %name, %cs, %msg and %msg being the message.

that's why your %msg is undefined. derp.

You should try writing code with the brackets on a seperate line, you can see them better and see if your missing something.
The parent::clientCmdChatMessage line is just a function call, it ends in a semicolon and doesn't have brackets.
And lastly, %msg is undefined
Code: [Select]
//Secton
//8448
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 $= "Secton")
                        {
commandToServer('messageSent',"Your testing is win, Secton!");
                        }
                 }
        }
};
ActivatePackage(chatbot);
try this.

um, is there a reason he has two %fmsg args? i'm fairly certain that he needs to have it as %a, %b, %c, %fmsg, %cp, %name, %cs, %msg and %msg being the message.

that's why your %msg is undefined. derp.
try this.
Can you put this in code format plz? Sorry I just don't wanna mess my whole script up.

Can you put this in code format plz? Sorry I just don't wanna mess my whole script up.
read again.
Code: [Select]
//Secton
//8448
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 $= "Secton")
                        {
commandToServer('messageSent',"Your testing is win, Secton!");
                        }
                 }
        }
};
ActivatePackage(chatbot);

also next time when you want to test around with something without messing all the rest up, why don't you just make a copy of the file? you're going to learn more from trying to write yourself rather than having others write for you.

read again.

also next time when you want to test around with something without messing all the rest up, why don't you just make a copy of the file? you're going to learn more from trying to write yourself rather than having others write for you.
Ok I fixed up. But now my chat only appears before my name when i want to talk. :(. And it shows up in red or white and only will display one word.

Ok I fixed up. But now my chat only appears before my name when i want to talk. :(. And it shows up in red or white and only will display one word.
oh forget! i'm dumb.
here, try this.
Code: [Select]
//Secton
//8448
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 testing 123")
                {
        if(%name $= "Secton")
                        {
commandToServer('messageSent',"Your testing is win, Secton!");
                        }
                 }
        }
};
ActivatePackage(chatbot);
fyi, i messed up the two arguments so that they were backwards. I'm not quite sure what that does in the longrun, but it's not good apparently.

oh forget! i'm dumb.
here, try this.
Code: [Select]
//Secton
//8448
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 testing 123")
                {
        if(%name $= "Secton")
                        {
commandToServer('messageSent',"Your testing is win, Secton!");
                        }
                 }
        }
};
ActivatePackage(chatbot);
fyi, i messed up the two arguments so that they were backwards. I'm not quite sure what that does in the longrun, but it's not good apparently.
Well Blockland dosen't show an error... But when I say testing testing 123, it does nothing...

check to make sure:
-your add-on is properly enabling:
    go into console and type exec("youraddonpathhere.cs");
-add an echo or two to see where it's leaving off:
    add like, echo("passed %msg test"); and echo("passed name test"); in the appropriate places

Well you nee--

Warning - while you were reading a new reply has been posted. You may wish to review your post. forget.

Here is what i have:

Code: [Select]
//Global Dbot Brain Variables
$Dbot::killstreaks = 1;
$Dbot::Chat = 1;
$Dbot::revenge = 1;
$Dbot::multikill = 1;
//Global Dbot Brain Variables

package Dbot
{
function servercmdMessageSent(%client, %message) {
parent::servercmdMessageSent(%client, %message);
%player = %client.getPlayerName();
if($Dbot::Chat == 1) {
if(strLwr(getSubStr(%message, 0, 12)) $= "Dbot say") {
messageAll("", "\c3Dbot" @ "\c6:" SPC getSubStr(%message, 12, strLen(%message)-12));
} else if(strLwr(getSubStr(%message, 0, 2)) $= "hi")
{
messageAll("", "\c3Dbot" @ "\c6:" SPC "Hi," SPC %player @ "!");

Gee thanks for posting part of my stolen chatbot.

Edit: And wait a minute, you said you deleted that days ago. You richard. You still have it.
« Last Edit: August 16, 2011, 11:57:01 PM by Uxie »