Author Topic: Chatbot Help  (Read 2320 times)

Oh you can remove all those echos
I put them in there for debugging to see where it was stopping somewhere I wasn't seeing, but forgot to remove them.

Logic errors:
Anyways, getWord and getWords start counting at 0, while getWordCount starts at 1. So change the last part of the if check for your subtraction, 'getWordCount(%msg) == 4' to 'getWordCount(%msg) == 5' and change '%b = getWord(%msg,5);' to '%b = getWord(%msg,4);'

You're also subtracting the wrong way: change '%c = %a - %b;' to '%c = %b - %a';


I don't see the syntax error though
« Last Edit: July 27, 2012, 06:27:57 PM by Headcrab Zombie »

Oh you can remove all those echos
I put them in there for debugging to see where it was stopping somewhere I wasn't seeing, but forgot to remove them.

Logic errors:
Anyways, getWord and getWords start counting at 0, while getWordCount starts at 1. So change the last part of the if check for your subtraction, 'getWordCount(%msg) == 4' to 'getWordCount(%msg) == 5' and change '%b = getWord(%msg,5);' to '%b = getWord(%msg,4);'

You're also subtracting the wrong way: change '%c = %a - %b;' to '%c = %b - %a';


I don't see the syntax error though

I did that, but now none of my commands respond :s
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(%name !$= $Pref::Player::NetName)
return;
if(%msg $= "Alchbot, Test Active")
{
commandToServer('messageSent',"[AlchBot]: Activity Test Succeed!");
}
else if(getWords(%msg, 0, 5) $= "Alchbot, generate a random number between" && getWord(%msg, 7) $= "and" && getWordCount(%msg) == 9)
{
%a = getWord(%msg,6);
%b = getWord(%msg,8);
%c = getRandom(%a,%b);
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
else if(getWords(%msg, 0, 1) $= "Alchbot, subtract" && getWord(%msg, 3) $= "from" && getWordCount(%msg) == 5)
{
%a = getWord(%msg,2);
%b = getWord(%msg,4);
%c = %a - %b;
commandToServer('messageSent',"[Alchbot]: The number returned was " @ %c);
}
else if(%msg $="Alchbot, Update")
{
exec("Add-Ons/Client_AlchBot/client.cs");
commandToServer('messageSent',"[Alchbot]: Systems updated.
}
}
}
};
activatePackage(Chatbot);

Because syntax error



Learn to use these. It gives a line number and general location of the error, with #### around the error.
You forgot an ending quotation mark, parenthesis, and semicolon;
Code: [Select]
commandToServer('messageSent',"[Alchbot]: Systems updated.should be
Code: [Select]
commandToServer('messageSent',"[Alchbot]: Systems updated.");
Fixing that reveals another syntax error, an extra curly bracket at the end

Because syntax error



Learn to use these. It gives a line number and general location of the error, with #### around the error.
You forgot an ending quotation mark, parenthesis, and semicolon;
Code: [Select]
commandToServer('messageSent',"[Alchbot]: Systems updated.should be
Code: [Select]
commandToServer('messageSent',"[Alchbot]: Systems updated.");
Fixing that reveals another syntax error, an extra curly bracket at the end
I'm so sloppy :c

don't worry
everyone does it on a regular basis