Author Topic: Whats wrong with this script?  (Read 4468 times)

Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 15 - Syntax error.
>>> Some error context, with ## on sides of error halt:
package chatbot

{

function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)





^{

^^parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

^if(%msg $= "hi"){

^commandToServer('commandSent',"Chatbot: Hi, "@%name);

^}

^

^

}
activatepackage(##c##hatbot);


>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

You need a ; after the closing bracket for the package

You need a ; after the closing bracket for the package
Did that, it spat another error back out.
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 14 - Syntax error.
>>> Some error context, with ## on sides of error halt:
//20053

package chatbot

{

function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)





^{

^^parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

^if(%msg $= "hi"){

^commandToServer('commandSent',"Chatbot: Hi, "@%name);

^}

^^

};##
##
activatepackage(chatbot);


>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

I count three opening and two closing brackets. The function never ended.

EDIT: Or more accurately, the package never ended and the function ended where the package should have.

I count three opening and two closing brackets. The function never ended.

EDIT: Or more accurately, the package never ended and the function ended where the package should have.
Would this fix it?
Code: [Select]
//MagicalTrafficConeRobot
//20053
package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%msg $= "hi"){
commandToServer('commandSent',"Chatbot: Hi, "@%name)
}
}
};
activatepackage(chatbot);

Would this fix it?
Code: [Select]
//MagicalTrafficConeRobot
//20053
package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%msg $= "hi"){
commandToServer('commandSent',"Chatbot: Hi, "@%name)
}
}
};
activatepackage(chatbot);

Yes it would.
Also, you used the tutorial from my website
<3

you still need a semicolon after the commandToServer call. the first argument of that should also be 'messageSent' instead of 'commandSent', if you're trying to send a chat message.

you still need a semicolon after the commandToServer call. the first argument of that should also be 'messageSent' instead of 'commandSent', if you're trying to send a chat message.
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 10 - Syntax error.
>>> Some error context, with ## on sides of error halt:
/MagicalTrafficConeRobot

//20053

package chatbot

{

function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

^{

^^parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

^if(%msg $= "hi"){

^commandToServer('messageSent',"Chatbot: Hi, "@%name)

^^^^^}##;##

^}

};

activatepackage(chatbot);


>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

I meant after the function's closing parenthesis.

I meant after the function's closing parenthesis.
Now THIS error comes up
I assume I put another semicolon where the #'s are?
Code: [Select]
Client checking Add-On: Client_Chatbot
Loading Add-On: Client_Chatbot
Add-Ons/Client_Chatbot/client.cs Line: 10 - Syntax error.
>>> Some error context, with ## on sides of error halt:
/MagicalTrafficConeRobot

//20053

package chatbot

{

function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)

^{

^^parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);

^if(%msg $= "hi"){

^commandToServer('messageSent',"Chatbot: Hi, "@%name)

^^^^^}##
##
^};

};

activatepackage(chatbot);


>>> Error report complete.

ADD-ON "Client_Chatbot" CONTAINS SYNTAX ERRORS

remove that semicolon, put it here:
commandToServer('messageSent',"Chatbot: Hi, "@%name); <--

remove that semicolon, put it here:
commandToServer('messageSent',"Chatbot: Hi, "@%name); <--
Thanks that worked.
Also, I have another question. How do I have to where I can say two things and it will respond with the same answer?

Thanks that worked.
Also, I have another question. How do I have to where I can say two things and it will respond with the same answer?

with what you have now, the easiest and most efficient solution is to use the or operator (||)

e.g.

if(%msg $= "hi" || %msg $= "hello")

does that make sense? this means the if block will run if either of those conditions are met.

you're not restricted to just two, though. this works fine as well:

if(%msg $= "hi" || %msg $= "hello" || %msg $= "tater tots" || %msg $= "strawberry soda")

be careful with that though, it can get messy and when you start getting more complex, you may need to use parenthesis to group things together.
« Last Edit: August 15, 2013, 07:44:31 PM by otto-san »

with what you have now, the easiest and most efficient solution is to use the or operator (||)

e.g.

if(%msg $= "hi" || %msg $= "hello")

does that make sense? this means the if block will run if either of those conditions are met.
Thank you, but I have one last question.
How do I get seperate answers? Like If I say help it gives me a help list or if I say hi it says hi?

Duplicate the function and edit it.