Author Topic: If Strstr Syntax Error in client-side script  (Read 1351 times)

Please fix this script problem...
Code: (Console Log) [Select]
Client checking Add-On: Client_FrogCM
Loading Add-On: Client_FrogCM (CRC:-606936464)
Add-Ons/Client_FrogCM/client.cs Line: 57 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^^commandtoserver('messagesent', "FrogCM Math: Calculates the square root of X and returns the result.");
^^}
^^else
^^{
^^^commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent");
^^}
^}
^if(##s##trstr("%msg","@math") == 0)
^{
^^commandtoserver('messagesent', "FrogCM Math: Calculating...");
^^{
^^if(strstr("%msg","trig") == 1)
^^^commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
^^}
^^else if(strstr("%msg","add") == 1)
^^{
^^^commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "+" @ getword(%msg, 3) SPC "=" @ getword(%msg, 2) + getword(%msg, 3));
>>> Error report complete.

ADD-ON "Client_FrogCM" CONTAINS SYNTAX ERRORS
Code: (TorqueScript) [Select]
warn("Loading FrogCM v0.1.2 (Unstable)");

package FrogCM
{
function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg) //srs chat mod here bro
{
if(%msg $= "@about")
commandtoserver('messagesent', "FrogCM v0.1.2: Made by Frogger3140.");
if(%msg $= "@cake")
commandtoserver('messagesent', "You," SPC %name @ ", deserve" SPC getrandom(10, 99) SPC "cakes!");
if(strstr("%msg","@mhelp") == 0)
commandtoserver('messagesent', "FrogCM Math: Looking for help topic...");
if(strstr("%msg","trig") == 1)
{
commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
}
else if(strstr("%msg","add") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math add x y");
commandtoserver('messagesent', "FrogCM Math: Adds X and Y and returns the result.");
}
else if(strstr("%msg","subtract") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math subtract x y");
commandtoserver('messagesent', "FrogCM Math: Subtracts X and Y and returns the result.");
}
else if(strstr("%msg","multiply") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math multiply x y");
commandtoserver('messagesent', "FrogCM Math: Multiplies X and Y and returns the result.");
}
else if(strstr("%msg","divide") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math divide x y");
commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result.");
}
else if(strstr("%msg","intdivide") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math intdivide x y");
commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result with its remainder.");
}
else if(strstr("%msg","exponent") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math exponent x y");
commandtoserver('messagesent', "FrogCM Math: Calculates X to the power of Y and returns the result.");
}
else if(strstr("%msg","squareroot") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math squareroot x");
commandtoserver('messagesent', "FrogCM Math: Calculates the square root of X and returns the result.");
}
else
{
commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent");
}
}
if(strstr("%msg","@math") == 0)
{
commandtoserver('messagesent', "FrogCM Math: Calculating...");
{
if(strstr("%msg","trig") == 1)
commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
}
else if(strstr("%msg","add") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "+" @ getword(%msg, 3) SPC "=" @ getword(%msg, 2) + getword(%msg, 3));
}
else if(strstr("%msg","subtract") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "-" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) - getword(%msg, 3));
}
else if(strstr("%msg","multiply") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "*" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) * getword(%msg, 3));
}
else if(strstr("%msg","divide") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) / getword(%msg, 3));
}
else if(strstr("%msg","intdivide") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC mFloor(getword(%msg, 2) / getword(%msg, 3)) SPC "r" @ getword(%msg, 2) % getword(%msg, 3));
}
else if(strstr("%msg","exponent") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "^" @ getword(%msg, 3) SPC "=" SPC mPow(getword(%msg, 2), getword(%msg, 3)));
}
else if(strstr("%msg","squareroot") == 1)
{
commandtoserver('messagesent', "FrogCM Math: sqrt" SPC getword(%msg, 2) SPC "=" SPC mSqrt(getword(%msg, 2)));
}
else
{
commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent");
}
}
if(%msg $= "@help")
{
commandtoserver('messagesent', "FrogCM Commands: @about: About FrogCM. @help: FrogCM Help. @cake: CAKE.");
commandtoserver('messagesent', "FrogCM Math: Use @mhelp Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, or Exponent");
}
parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);

}
};
activatepackage(FrogCM);

echo("FrogCM Load Success!");

Fixed, added correct spacing:
Code: [Select]
package FrogCM
{
function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg) //srs chat mod here bro
{
if(%msg $= "@about")
commandtoserver('messagesent', "FrogCM v0.1.2: Made by Frogger3140.");
if(%msg $= "@cake")
commandtoserver('messagesent', "You," SPC %name @ ", deserve" SPC getrandom(10, 99) SPC "cakes!");
if(strstr("%msg","@mhelp") == 0)
{
commandtoserver('messagesent', "FrogCM Math: Looking for help topic...");
if(strstr("%msg","trig") == 1)
{
commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
}
else if(strstr("%msg","add") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math add x y");
commandtoserver('messagesent', "FrogCM Math: Adds X and Y and returns the result.");
}
else if(strstr("%msg","subtract") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math subtract x y");
commandtoserver('messagesent', "FrogCM Math: Subtracts X and Y and returns the result.");
}
else if(strstr("%msg","multiply") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math multiply x y");
commandtoserver('messagesent', "FrogCM Math: Multiplies X and Y and returns the result.");
}
else if(strstr("%msg","divide") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math divide x y");
commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result.");
}
else if(strstr("%msg","intdivide") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math intdivide x y");
commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result with its remainder.");
}
else if(strstr("%msg","exponent") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math exponent x y");
commandtoserver('messagesent', "FrogCM Math: Calculates X to the power of Y and returns the result.");
}
else if(strstr("%msg","squareroot") == 1)
{
commandtoserver('messagesent', "FrogCM Math: @math squareroot x");
commandtoserver('messagesent', "FrogCM Math: Calculates the square root of X and returns the result.");
}
else
{
commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent");
}
}
if(strstr("%msg","@math") == 0)
{
commandtoserver('messagesent', "FrogCM Math: Calculating...");
{
if(strstr("%msg","trig") == 1)
commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
}
else if(strstr("%msg","add") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "+" @ getword(%msg, 3) SPC "=" @ getword(%msg, 2) + getword(%msg, 3));
}
else if(strstr("%msg","subtract") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "-" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) - getword(%msg, 3));
}
else if(strstr("%msg","multiply") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "*" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) * getword(%msg, 3));
}
else if(strstr("%msg","divide") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) / getword(%msg, 3));
}
else if(strstr("%msg","intdivide") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC mFloor(getword(%msg, 2) / getword(%msg, 3)) SPC "r" @ getword(%msg, 2) % getword(%msg, 3));
}
else if(strstr("%msg","exponent") == 1)
{
commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "^" @ getword(%msg, 3) SPC "=" SPC mPow(getword(%msg, 2), getword(%msg, 3)));
}
else if(strstr("%msg","squareroot") == 1)
{
commandtoserver('messagesent', "FrogCM Math: sqrt" SPC getword(%msg, 2) SPC "=" SPC mSqrt(getword(%msg, 2)));
}
else
{
commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent");
}
}
if(%msg $= "@help")
{
commandtoserver('messagesent', "FrogCM Commands: @about: About FrogCM. @help: FrogCM Help. @cake: CAKE.");
commandtoserver('messagesent', "FrogCM Math: Use @mhelp Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, or Exponent");
}
parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);

}
};
activatepackage(FrogCM);

you could've edited the first post
and also, the ##(letter)## means that there is an error before it, i think
and in this case, you had an extra { right above it

commandtoserver('messagesent', "FrogCM Math: Calculating...");
         {
         if(strstr("%msg","trig") == 1)
            commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
         }
should turn into
commandtoserver('messagesent', "FrogCM Math: Calculating...");
         if(strstr("%msg","trig") == 1)
         {
            commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");
         }
or
commandtoserver('messagesent', "FrogCM Math: Calculating...");
         if(strstr("%msg","trig") == 1)
            commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2");

you could've edited the first post

ZNSO can edit frogger3140's posts? Is he some kind of hacker?

You should really use some kind of command system, like

Code: [Select]
package FrogCM
{
    function clientCmdChatMessage(%cl,%a,%b,%line,%pre,%name,%suf,%msg,%x)
    {
        Parent::clientCmdChatMessage(%cl,%a,%b,%line,%pre,%name,%suf,%msg,%x);
        if(getSubStr(%msg,0,1) $= "@")
        {
            %msg = getSubStr(%msg,1,strLen(%msg));
            %cmd = firstWord(%msg);
            %arg = restWords(%msg);
            if(isFunction(%func = "frogCmd" @ %cmd))
                call(%func, %name, %arg);
        }
    }
};
function frogCmdDie(%name, %arg)
{
    if(%arg $= "horribly")
        crash();
    else
        quit();
}

Oh boy. Another chat bot. How 'enjoyable'.

Keep this crap in a GUI please.

ZNSO can edit frogger3140's posts? Is he some kind of hacker?
oops, just saw the blocks of code, and the break of the line, didn't look at the avatar :D