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


Jesus. Let me give you a tip real fast: code formatting is important. It allows you to see errors much more easily.

For example:
Code: [Select]
function exampleOne()
{
    if(getRandom(0,1) == 0)
    {
        echo("Hello!");
    echo("Example run.");
}

In this example, with proper formatting, it's easy to see that a closing bracket is missing. It may seem like extra work, but on top of making debugging easier for yourself it makes it easier for other people to read and understand your code.


However, in this case, you've actually done nothing wrong. All I did was format your code and run it and it worked.



Anyway, to put you in the right direction, here's your same exact code (but formatted).

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(%msg $= "MB>Index")
{
commandToServer('messageSent',"MagicBot: Commands, Rules, News");
}
if(%msg $= "MB>Commands")
{
commandToServer('messageSent',"MagicBot: MBAnno:restwords");
}
if(firstWord(%msg) $= "MBAnno:")
{
commandToServer('messageSent',"MagicBot: "@restWords(%msg));
}
}
};
activatepackage(chatbot);
« Last Edit: August 18, 2013, 01:50:48 PM by $trinick »